Update to drupal-org-drupal 8.0.0-rc2. For more information, see https://www.drupal.org/node/2598668
This commit is contained in:
parent
f32e58e4b1
commit
8e18df8c36
3062 changed files with 15044 additions and 172506 deletions
|
@ -1,281 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the PHP_CodeCoverage package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
if (!defined('TEST_FILES_PATH')) {
|
||||
define(
|
||||
'TEST_FILES_PATH',
|
||||
dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR .
|
||||
'_files' . DIRECTORY_SEPARATOR
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests for the PHP_CodeCoverage_Filter class.
|
||||
*
|
||||
* @since Class available since Release 1.0.0
|
||||
*/
|
||||
class PHP_CodeCoverage_FilterTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected $filter;
|
||||
protected $files;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->filter = unserialize('O:23:"PHP_CodeCoverage_Filter":0:{}');
|
||||
|
||||
$this->files = array(
|
||||
TEST_FILES_PATH . 'BankAccount.php',
|
||||
TEST_FILES_PATH . 'BankAccountTest.php',
|
||||
TEST_FILES_PATH . 'CoverageClassExtendedTest.php',
|
||||
TEST_FILES_PATH . 'CoverageClassTest.php',
|
||||
TEST_FILES_PATH . 'CoverageFunctionParenthesesTest.php',
|
||||
TEST_FILES_PATH . 'CoverageFunctionParenthesesWhitespaceTest.php',
|
||||
TEST_FILES_PATH . 'CoverageFunctionTest.php',
|
||||
TEST_FILES_PATH . 'CoverageMethodOneLineAnnotationTest.php',
|
||||
TEST_FILES_PATH . 'CoverageMethodParenthesesTest.php',
|
||||
TEST_FILES_PATH . 'CoverageMethodParenthesesWhitespaceTest.php',
|
||||
TEST_FILES_PATH . 'CoverageMethodTest.php',
|
||||
TEST_FILES_PATH . 'CoverageNoneTest.php',
|
||||
TEST_FILES_PATH . 'CoverageNotPrivateTest.php',
|
||||
TEST_FILES_PATH . 'CoverageNotProtectedTest.php',
|
||||
TEST_FILES_PATH . 'CoverageNotPublicTest.php',
|
||||
TEST_FILES_PATH . 'CoverageNothingTest.php',
|
||||
TEST_FILES_PATH . 'CoveragePrivateTest.php',
|
||||
TEST_FILES_PATH . 'CoverageProtectedTest.php',
|
||||
TEST_FILES_PATH . 'CoveragePublicTest.php',
|
||||
TEST_FILES_PATH . 'CoverageTwoDefaultClassAnnotations.php',
|
||||
TEST_FILES_PATH . 'CoveredClass.php',
|
||||
TEST_FILES_PATH . 'CoveredFunction.php',
|
||||
TEST_FILES_PATH . 'NamespaceCoverageClassExtendedTest.php',
|
||||
TEST_FILES_PATH . 'NamespaceCoverageClassTest.php',
|
||||
TEST_FILES_PATH . 'NamespaceCoverageCoversClassPublicTest.php',
|
||||
TEST_FILES_PATH . 'NamespaceCoverageCoversClassTest.php',
|
||||
TEST_FILES_PATH . 'NamespaceCoverageMethodTest.php',
|
||||
TEST_FILES_PATH . 'NamespaceCoverageNotPrivateTest.php',
|
||||
TEST_FILES_PATH . 'NamespaceCoverageNotProtectedTest.php',
|
||||
TEST_FILES_PATH . 'NamespaceCoverageNotPublicTest.php',
|
||||
TEST_FILES_PATH . 'NamespaceCoveragePrivateTest.php',
|
||||
TEST_FILES_PATH . 'NamespaceCoverageProtectedTest.php',
|
||||
TEST_FILES_PATH . 'NamespaceCoveragePublicTest.php',
|
||||
TEST_FILES_PATH . 'NamespaceCoveredClass.php',
|
||||
TEST_FILES_PATH . 'NotExistingCoveredElementTest.php',
|
||||
TEST_FILES_PATH . 'source_with_class_and_anonymous_function.php',
|
||||
TEST_FILES_PATH . 'source_with_ignore.php',
|
||||
TEST_FILES_PATH . 'source_with_namespace.php',
|
||||
TEST_FILES_PATH . 'source_with_oneline_annotations.php',
|
||||
TEST_FILES_PATH . 'source_without_ignore.php',
|
||||
TEST_FILES_PATH . 'source_without_namespace.php'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_CodeCoverage_Filter::addFileToBlacklist
|
||||
* @covers PHP_CodeCoverage_Filter::getBlacklist
|
||||
*/
|
||||
public function testAddingAFileToTheBlacklistWorks()
|
||||
{
|
||||
$this->filter->addFileToBlacklist($this->files[0]);
|
||||
|
||||
$this->assertEquals(
|
||||
array($this->files[0]),
|
||||
$this->filter->getBlacklist()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_CodeCoverage_Filter::removeFileFromBlacklist
|
||||
* @covers PHP_CodeCoverage_Filter::getBlacklist
|
||||
*/
|
||||
public function testRemovingAFileFromTheBlacklistWorks()
|
||||
{
|
||||
$this->filter->addFileToBlacklist($this->files[0]);
|
||||
$this->filter->removeFileFromBlacklist($this->files[0]);
|
||||
|
||||
$this->assertEquals(array(), $this->filter->getBlacklist());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_CodeCoverage_Filter::addDirectoryToBlacklist
|
||||
* @covers PHP_CodeCoverage_Filter::getBlacklist
|
||||
* @depends testAddingAFileToTheBlacklistWorks
|
||||
*/
|
||||
public function testAddingADirectoryToTheBlacklistWorks()
|
||||
{
|
||||
$this->filter->addDirectoryToBlacklist(TEST_FILES_PATH);
|
||||
|
||||
$blacklist = $this->filter->getBlacklist();
|
||||
sort($blacklist);
|
||||
|
||||
$this->assertEquals($this->files, $blacklist);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_CodeCoverage_Filter::addFilesToBlacklist
|
||||
* @covers PHP_CodeCoverage_Filter::getBlacklist
|
||||
*/
|
||||
public function testAddingFilesToTheBlacklistWorks()
|
||||
{
|
||||
$facade = new File_Iterator_Facade;
|
||||
$files = $facade->getFilesAsArray(
|
||||
TEST_FILES_PATH,
|
||||
$suffixes = '.php'
|
||||
);
|
||||
|
||||
$this->filter->addFilesToBlacklist($files);
|
||||
|
||||
$blacklist = $this->filter->getBlacklist();
|
||||
sort($blacklist);
|
||||
|
||||
$this->assertEquals($this->files, $blacklist);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_CodeCoverage_Filter::removeDirectoryFromBlacklist
|
||||
* @covers PHP_CodeCoverage_Filter::getBlacklist
|
||||
* @depends testAddingADirectoryToTheBlacklistWorks
|
||||
*/
|
||||
public function testRemovingADirectoryFromTheBlacklistWorks()
|
||||
{
|
||||
$this->filter->addDirectoryToBlacklist(TEST_FILES_PATH);
|
||||
$this->filter->removeDirectoryFromBlacklist(TEST_FILES_PATH);
|
||||
|
||||
$this->assertEquals(array(), $this->filter->getBlacklist());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_CodeCoverage_Filter::addFileToWhitelist
|
||||
* @covers PHP_CodeCoverage_Filter::getWhitelist
|
||||
*/
|
||||
public function testAddingAFileToTheWhitelistWorks()
|
||||
{
|
||||
$this->filter->addFileToWhitelist($this->files[0]);
|
||||
|
||||
$this->assertEquals(
|
||||
array($this->files[0]),
|
||||
$this->filter->getWhitelist()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_CodeCoverage_Filter::removeFileFromWhitelist
|
||||
* @covers PHP_CodeCoverage_Filter::getWhitelist
|
||||
*/
|
||||
public function testRemovingAFileFromTheWhitelistWorks()
|
||||
{
|
||||
$this->filter->addFileToWhitelist($this->files[0]);
|
||||
$this->filter->removeFileFromWhitelist($this->files[0]);
|
||||
|
||||
$this->assertEquals(array(), $this->filter->getWhitelist());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_CodeCoverage_Filter::addDirectoryToWhitelist
|
||||
* @covers PHP_CodeCoverage_Filter::getWhitelist
|
||||
* @depends testAddingAFileToTheWhitelistWorks
|
||||
*/
|
||||
public function testAddingADirectoryToTheWhitelistWorks()
|
||||
{
|
||||
$this->filter->addDirectoryToWhitelist(TEST_FILES_PATH);
|
||||
|
||||
$whitelist = $this->filter->getWhitelist();
|
||||
sort($whitelist);
|
||||
|
||||
$this->assertEquals($this->files, $whitelist);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_CodeCoverage_Filter::addFilesToWhitelist
|
||||
* @covers PHP_CodeCoverage_Filter::getBlacklist
|
||||
*/
|
||||
public function testAddingFilesToTheWhitelistWorks()
|
||||
{
|
||||
$facade = new File_Iterator_Facade;
|
||||
$files = $facade->getFilesAsArray(
|
||||
TEST_FILES_PATH,
|
||||
$suffixes = '.php'
|
||||
);
|
||||
|
||||
$this->filter->addFilesToWhitelist($files);
|
||||
|
||||
$whitelist = $this->filter->getWhitelist();
|
||||
sort($whitelist);
|
||||
|
||||
$this->assertEquals($this->files, $whitelist);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_CodeCoverage_Filter::removeDirectoryFromWhitelist
|
||||
* @covers PHP_CodeCoverage_Filter::getWhitelist
|
||||
* @depends testAddingADirectoryToTheWhitelistWorks
|
||||
*/
|
||||
public function testRemovingADirectoryFromTheWhitelistWorks()
|
||||
{
|
||||
$this->filter->addDirectoryToWhitelist(TEST_FILES_PATH);
|
||||
$this->filter->removeDirectoryFromWhitelist(TEST_FILES_PATH);
|
||||
|
||||
$this->assertEquals(array(), $this->filter->getWhitelist());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_CodeCoverage_Filter::isFile
|
||||
*/
|
||||
public function testIsFile()
|
||||
{
|
||||
$this->assertFalse($this->filter->isFile('vfs://root/a/path'));
|
||||
$this->assertFalse($this->filter->isFile('xdebug://debug-eval'));
|
||||
$this->assertFalse($this->filter->isFile('eval()\'d code'));
|
||||
$this->assertFalse($this->filter->isFile('runtime-created function'));
|
||||
$this->assertFalse($this->filter->isFile('assert code'));
|
||||
$this->assertFalse($this->filter->isFile('regexp code'));
|
||||
$this->assertTrue($this->filter->isFile(__FILE__));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_CodeCoverage_Filter::isFiltered
|
||||
*/
|
||||
public function testBlacklistedFileIsFiltered()
|
||||
{
|
||||
$this->filter->addFileToBlacklist($this->files[0]);
|
||||
$this->assertTrue($this->filter->isFiltered($this->files[0]));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_CodeCoverage_Filter::isFiltered
|
||||
*/
|
||||
public function testWhitelistedFileIsNotFiltered()
|
||||
{
|
||||
$this->filter->addFileToWhitelist($this->files[0]);
|
||||
$this->assertFalse($this->filter->isFiltered($this->files[0]));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_CodeCoverage_Filter::isFiltered
|
||||
*/
|
||||
public function testNotWhitelistedFileIsFiltered()
|
||||
{
|
||||
$this->filter->addFileToWhitelist($this->files[0]);
|
||||
$this->assertTrue($this->filter->isFiltered($this->files[1]));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_CodeCoverage_Filter::isFiltered
|
||||
* @covers PHP_CodeCoverage_Filter::isFile
|
||||
*/
|
||||
public function testNonFilesAreFiltered()
|
||||
{
|
||||
$this->assertTrue($this->filter->isFiltered('vfs://root/a/path'));
|
||||
$this->assertTrue($this->filter->isFiltered('xdebug://debug-eval'));
|
||||
$this->assertTrue($this->filter->isFiltered('eval()\'d code'));
|
||||
$this->assertTrue($this->filter->isFiltered('runtime-created function'));
|
||||
$this->assertTrue($this->filter->isFiltered('assert code'));
|
||||
$this->assertTrue($this->filter->isFiltered('regexp code'));
|
||||
$this->assertFalse($this->filter->isFiltered(__FILE__));
|
||||
}
|
||||
}
|
|
@ -1,66 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the PHP_CodeCoverage package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
if (!defined('TEST_FILES_PATH')) {
|
||||
define(
|
||||
'TEST_FILES_PATH',
|
||||
dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR .
|
||||
'_files' . DIRECTORY_SEPARATOR
|
||||
);
|
||||
}
|
||||
|
||||
require_once TEST_FILES_PATH . '../TestCase.php';
|
||||
|
||||
/**
|
||||
* Tests for the PHP_CodeCoverage_Report_Clover class.
|
||||
*
|
||||
* @since Class available since Release 1.0.0
|
||||
*/
|
||||
class PHP_CodeCoverage_Report_CloverTest extends PHP_CodeCoverage_TestCase
|
||||
{
|
||||
/**
|
||||
* @covers PHP_CodeCoverage_Report_Clover
|
||||
*/
|
||||
public function testCloverForBankAccountTest()
|
||||
{
|
||||
$clover = new PHP_CodeCoverage_Report_Clover;
|
||||
|
||||
$this->assertStringMatchesFormatFile(
|
||||
TEST_FILES_PATH . 'BankAccount-clover.xml',
|
||||
$clover->process($this->getCoverageForBankAccount(), null, 'BankAccount')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_CodeCoverage_Report_Clover
|
||||
*/
|
||||
public function testCloverForFileWithIgnoredLines()
|
||||
{
|
||||
$clover = new PHP_CodeCoverage_Report_Clover;
|
||||
|
||||
$this->assertStringMatchesFormatFile(
|
||||
TEST_FILES_PATH . 'ignored-lines-clover.xml',
|
||||
$clover->process($this->getCoverageForFileWithIgnoredLines())
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_CodeCoverage_Report_Clover
|
||||
*/
|
||||
public function testCloverForClassWithAnonymousFunction()
|
||||
{
|
||||
$clover = new PHP_CodeCoverage_Report_Clover;
|
||||
|
||||
$this->assertStringMatchesFormatFile(
|
||||
TEST_FILES_PATH . 'class-with-anonymous-function-clover.xml',
|
||||
$clover->process($this->getCoverageForClassWithAnonymousFunction())
|
||||
);
|
||||
}
|
||||
}
|
|
@ -1,222 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the PHP_CodeCoverage package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
if (!defined('TEST_FILES_PATH')) {
|
||||
define(
|
||||
'TEST_FILES_PATH',
|
||||
dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR .
|
||||
'_files' . DIRECTORY_SEPARATOR
|
||||
);
|
||||
}
|
||||
|
||||
require_once TEST_FILES_PATH . '../TestCase.php';
|
||||
|
||||
/**
|
||||
* Tests for the PHP_CodeCoverage_Report_Factory class.
|
||||
*
|
||||
* @since Class available since Release 1.1.0
|
||||
*/
|
||||
class PHP_CodeCoverage_Report_FactoryTest extends PHP_CodeCoverage_TestCase
|
||||
{
|
||||
protected $factory;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->factory = new PHP_CodeCoverage_Report_Factory;
|
||||
}
|
||||
|
||||
public function testSomething()
|
||||
{
|
||||
$root = $this->getCoverageForBankAccount()->getReport();
|
||||
|
||||
$expectedPath = rtrim(TEST_FILES_PATH, DIRECTORY_SEPARATOR);
|
||||
$this->assertEquals($expectedPath, $root->getName());
|
||||
$this->assertEquals($expectedPath, $root->getPath());
|
||||
$this->assertEquals(10, $root->getNumExecutableLines());
|
||||
$this->assertEquals(5, $root->getNumExecutedLines());
|
||||
$this->assertEquals(1, $root->getNumClasses());
|
||||
$this->assertEquals(0, $root->getNumTestedClasses());
|
||||
$this->assertEquals(4, $root->getNumMethods());
|
||||
$this->assertEquals(3, $root->getNumTestedMethods());
|
||||
$this->assertEquals('0.00%', $root->getTestedClassesPercent());
|
||||
$this->assertEquals('75.00%', $root->getTestedMethodsPercent());
|
||||
$this->assertEquals('50.00%', $root->getLineExecutedPercent());
|
||||
$this->assertEquals(0, $root->getNumFunctions());
|
||||
$this->assertEquals(0, $root->getNumTestedFunctions());
|
||||
$this->assertNull($root->getParent());
|
||||
$this->assertEquals(array(), $root->getDirectories());
|
||||
#$this->assertEquals(array(), $root->getFiles());
|
||||
#$this->assertEquals(array(), $root->getChildNodes());
|
||||
|
||||
$this->assertEquals(
|
||||
array(
|
||||
'BankAccount' => array(
|
||||
'methods' => array(
|
||||
'getBalance' => array(
|
||||
'signature' => 'getBalance()',
|
||||
'startLine' => 6,
|
||||
'endLine' => 9,
|
||||
'executableLines' => 1,
|
||||
'executedLines' => 1,
|
||||
'ccn' => 1,
|
||||
'coverage' => 100,
|
||||
'crap' => '1',
|
||||
'link' => 'BankAccount.php.html#6',
|
||||
'methodName' => 'getBalance'
|
||||
),
|
||||
'setBalance' => array(
|
||||
'signature' => 'setBalance($balance)',
|
||||
'startLine' => 11,
|
||||
'endLine' => 18,
|
||||
'executableLines' => 5,
|
||||
'executedLines' => 0,
|
||||
'ccn' => 2,
|
||||
'coverage' => 0,
|
||||
'crap' => 6,
|
||||
'link' => 'BankAccount.php.html#11',
|
||||
'methodName' => 'setBalance'
|
||||
),
|
||||
'depositMoney' => array(
|
||||
'signature' => 'depositMoney($balance)',
|
||||
'startLine' => 20,
|
||||
'endLine' => 25,
|
||||
'executableLines' => 2,
|
||||
'executedLines' => 2,
|
||||
'ccn' => 1,
|
||||
'coverage' => 100,
|
||||
'crap' => '1',
|
||||
'link' => 'BankAccount.php.html#20',
|
||||
'methodName' => 'depositMoney'
|
||||
),
|
||||
'withdrawMoney' => array(
|
||||
'signature' => 'withdrawMoney($balance)',
|
||||
'startLine' => 27,
|
||||
'endLine' => 32,
|
||||
'executableLines' => 2,
|
||||
'executedLines' => 2,
|
||||
'ccn' => 1,
|
||||
'coverage' => 100,
|
||||
'crap' => '1',
|
||||
'link' => 'BankAccount.php.html#27',
|
||||
'methodName' => 'withdrawMoney'
|
||||
),
|
||||
),
|
||||
'startLine' => 2,
|
||||
'executableLines' => 10,
|
||||
'executedLines' => 5,
|
||||
'ccn' => 5,
|
||||
'coverage' => 50,
|
||||
'crap' => '8.12',
|
||||
'package' => array(
|
||||
'namespace' => '',
|
||||
'fullPackage' => '',
|
||||
'category' => '',
|
||||
'package' => '',
|
||||
'subpackage' => ''
|
||||
),
|
||||
'link' => 'BankAccount.php.html#2',
|
||||
'className' => 'BankAccount'
|
||||
)
|
||||
),
|
||||
$root->getClasses()
|
||||
);
|
||||
|
||||
$this->assertEquals(array(), $root->getFunctions());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_CodeCoverage_Report_Factory::buildDirectoryStructure
|
||||
*/
|
||||
public function testBuildDirectoryStructure()
|
||||
{
|
||||
$method = new ReflectionMethod(
|
||||
'PHP_CodeCoverage_Report_Factory',
|
||||
'buildDirectoryStructure'
|
||||
);
|
||||
|
||||
$method->setAccessible(true);
|
||||
|
||||
$this->assertEquals(
|
||||
array(
|
||||
'src' => array(
|
||||
'Money.php/f' => array(),
|
||||
'MoneyBag.php/f' => array()
|
||||
)
|
||||
),
|
||||
$method->invoke(
|
||||
$this->factory,
|
||||
array('src/Money.php' => array(), 'src/MoneyBag.php' => array())
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_CodeCoverage_Report_Factory::reducePaths
|
||||
* @dataProvider reducePathsProvider
|
||||
*/
|
||||
public function testReducePaths($reducedPaths, $commonPath, $paths)
|
||||
{
|
||||
$method = new ReflectionMethod(
|
||||
'PHP_CodeCoverage_Report_Factory',
|
||||
'reducePaths'
|
||||
);
|
||||
|
||||
$method->setAccessible(true);
|
||||
|
||||
$_commonPath = $method->invokeArgs($this->factory, array(&$paths));
|
||||
|
||||
$this->assertEquals($reducedPaths, $paths);
|
||||
$this->assertEquals($commonPath, $_commonPath);
|
||||
}
|
||||
|
||||
public function reducePathsProvider()
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
array(
|
||||
'Money.php' => array(),
|
||||
'MoneyBag.php' => array()
|
||||
),
|
||||
'/home/sb/Money',
|
||||
array(
|
||||
'/home/sb/Money/Money.php' => array(),
|
||||
'/home/sb/Money/MoneyBag.php' => array()
|
||||
)
|
||||
),
|
||||
array(
|
||||
array(
|
||||
'Money.php' => array()
|
||||
),
|
||||
'/home/sb/Money/',
|
||||
array(
|
||||
'/home/sb/Money/Money.php' => array()
|
||||
)
|
||||
),
|
||||
array(
|
||||
array(),
|
||||
'.',
|
||||
array()
|
||||
),
|
||||
array(
|
||||
array(
|
||||
'Money.php' => array(),
|
||||
'MoneyBag.php' => array(),
|
||||
'Cash.phar/Cash.php' => array(),
|
||||
),
|
||||
'/home/sb/Money',
|
||||
array(
|
||||
'/home/sb/Money/Money.php' => array(),
|
||||
'/home/sb/Money/MoneyBag.php' => array(),
|
||||
'phar:///home/sb/Money/Cash.phar/Cash.php' => array(),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the PHP_CodeCoverage package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Tests for the PHP_CodeCoverage_Util class.
|
||||
*
|
||||
* @since Class available since Release 1.0.0
|
||||
*/
|
||||
class PHP_CodeCoverage_UtilTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @covers PHP_CodeCoverage_Util::percent
|
||||
*/
|
||||
public function testPercent()
|
||||
{
|
||||
$this->assertEquals(100, PHP_CodeCoverage_Util::percent(100, 0));
|
||||
$this->assertEquals(100, PHP_CodeCoverage_Util::percent(100, 100));
|
||||
$this->assertEquals(
|
||||
'100.00%',
|
||||
PHP_CodeCoverage_Util::percent(100, 100, true)
|
||||
);
|
||||
}
|
||||
}
|
|
@ -1,487 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the PHP_CodeCoverage package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
if (!defined('TEST_FILES_PATH')) {
|
||||
define(
|
||||
'TEST_FILES_PATH',
|
||||
dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR .
|
||||
'_files' . DIRECTORY_SEPARATOR
|
||||
);
|
||||
}
|
||||
|
||||
require_once TEST_FILES_PATH . '../TestCase.php';
|
||||
require_once TEST_FILES_PATH . 'BankAccount.php';
|
||||
require_once TEST_FILES_PATH . 'BankAccountTest.php';
|
||||
|
||||
/**
|
||||
* Tests for the PHP_CodeCoverage class.
|
||||
*
|
||||
* @since Class available since Release 1.0.0
|
||||
*/
|
||||
class PHP_CodeCoverageTest extends PHP_CodeCoverage_TestCase
|
||||
{
|
||||
/**
|
||||
* @var PHP_CodeCoverage
|
||||
*/
|
||||
private $coverage;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->coverage = new PHP_CodeCoverage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_CodeCoverage::__construct
|
||||
* @covers PHP_CodeCoverage::filter
|
||||
*/
|
||||
public function testConstructor()
|
||||
{
|
||||
$this->assertAttributeInstanceOf(
|
||||
'PHP_CodeCoverage_Driver_Xdebug',
|
||||
'driver',
|
||||
$this->coverage
|
||||
);
|
||||
|
||||
$this->assertAttributeInstanceOf(
|
||||
'PHP_CodeCoverage_Filter',
|
||||
'filter',
|
||||
$this->coverage
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_CodeCoverage::__construct
|
||||
* @covers PHP_CodeCoverage::filter
|
||||
*/
|
||||
public function testConstructor2()
|
||||
{
|
||||
$filter = new PHP_CodeCoverage_Filter;
|
||||
$coverage = new PHP_CodeCoverage(null, $filter);
|
||||
|
||||
$this->assertAttributeInstanceOf(
|
||||
'PHP_CodeCoverage_Driver_Xdebug',
|
||||
'driver',
|
||||
$coverage
|
||||
);
|
||||
|
||||
$this->assertSame($filter, $coverage->filter());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_CodeCoverage::start
|
||||
* @expectedException PHP_CodeCoverage_Exception
|
||||
*/
|
||||
public function testStartThrowsExceptionForInvalidArgument()
|
||||
{
|
||||
$this->coverage->start(null, array(), null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_CodeCoverage::stop
|
||||
* @expectedException PHP_CodeCoverage_Exception
|
||||
*/
|
||||
public function testStopThrowsExceptionForInvalidArgument()
|
||||
{
|
||||
$this->coverage->stop(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_CodeCoverage::stop
|
||||
* @expectedException PHP_CodeCoverage_Exception
|
||||
*/
|
||||
public function testStopThrowsExceptionForInvalidArgument2()
|
||||
{
|
||||
$this->coverage->stop(true, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_CodeCoverage::append
|
||||
* @expectedException PHP_CodeCoverage_Exception
|
||||
*/
|
||||
public function testAppendThrowsExceptionForInvalidArgument()
|
||||
{
|
||||
$this->coverage->append(array(), null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_CodeCoverage::setCacheTokens
|
||||
* @expectedException PHP_CodeCoverage_Exception
|
||||
*/
|
||||
public function testSetCacheTokensThrowsExceptionForInvalidArgument()
|
||||
{
|
||||
$this->coverage->setCacheTokens(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_CodeCoverage::setCacheTokens
|
||||
*/
|
||||
public function testSetCacheTokens()
|
||||
{
|
||||
$this->coverage->setCacheTokens(true);
|
||||
$this->assertAttributeEquals(true, 'cacheTokens', $this->coverage);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_CodeCoverage::setCheckForUnintentionallyCoveredCode
|
||||
* @expectedException PHP_CodeCoverage_Exception
|
||||
*/
|
||||
public function testSetCheckForUnintentionallyCoveredCodeThrowsExceptionForInvalidArgument()
|
||||
{
|
||||
$this->coverage->setCheckForUnintentionallyCoveredCode(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_CodeCoverage::setCheckForUnintentionallyCoveredCode
|
||||
*/
|
||||
public function testSetCheckForUnintentionallyCoveredCode()
|
||||
{
|
||||
$this->coverage->setCheckForUnintentionallyCoveredCode(true);
|
||||
$this->assertAttributeEquals(
|
||||
true,
|
||||
'checkForUnintentionallyCoveredCode',
|
||||
$this->coverage
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_CodeCoverage::setForceCoversAnnotation
|
||||
* @expectedException PHP_CodeCoverage_Exception
|
||||
*/
|
||||
public function testSetForceCoversAnnotationThrowsExceptionForInvalidArgument()
|
||||
{
|
||||
$this->coverage->setForceCoversAnnotation(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_CodeCoverage::setForceCoversAnnotation
|
||||
*/
|
||||
public function testSetForceCoversAnnotation()
|
||||
{
|
||||
$this->coverage->setForceCoversAnnotation(true);
|
||||
$this->assertAttributeEquals(
|
||||
true,
|
||||
'forceCoversAnnotation',
|
||||
$this->coverage
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_CodeCoverage::setAddUncoveredFilesFromWhitelist
|
||||
* @expectedException PHP_CodeCoverage_Exception
|
||||
*/
|
||||
public function testSetAddUncoveredFilesFromWhitelistThrowsExceptionForInvalidArgument()
|
||||
{
|
||||
$this->coverage->setAddUncoveredFilesFromWhitelist(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_CodeCoverage::setAddUncoveredFilesFromWhitelist
|
||||
*/
|
||||
public function testSetAddUncoveredFilesFromWhitelist()
|
||||
{
|
||||
$this->coverage->setAddUncoveredFilesFromWhitelist(true);
|
||||
$this->assertAttributeEquals(
|
||||
true,
|
||||
'addUncoveredFilesFromWhitelist',
|
||||
$this->coverage
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_CodeCoverage::setProcessUncoveredFilesFromWhitelist
|
||||
* @expectedException PHP_CodeCoverage_Exception
|
||||
*/
|
||||
public function testSetProcessUncoveredFilesFromWhitelistThrowsExceptionForInvalidArgument()
|
||||
{
|
||||
$this->coverage->setProcessUncoveredFilesFromWhitelist(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_CodeCoverage::setProcessUncoveredFilesFromWhitelist
|
||||
*/
|
||||
public function testSetProcessUncoveredFilesFromWhitelist()
|
||||
{
|
||||
$this->coverage->setProcessUncoveredFilesFromWhitelist(true);
|
||||
$this->assertAttributeEquals(
|
||||
true,
|
||||
'processUncoveredFilesFromWhitelist',
|
||||
$this->coverage
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_CodeCoverage::setMapTestClassNameToCoveredClassName
|
||||
*/
|
||||
public function testSetMapTestClassNameToCoveredClassName()
|
||||
{
|
||||
$this->coverage->setMapTestClassNameToCoveredClassName(true);
|
||||
$this->assertAttributeEquals(
|
||||
true,
|
||||
'mapTestClassNameToCoveredClassName',
|
||||
$this->coverage
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_CodeCoverage::setMapTestClassNameToCoveredClassName
|
||||
* @expectedException PHP_CodeCoverage_Exception
|
||||
*/
|
||||
public function testSetMapTestClassNameToCoveredClassNameThrowsExceptionForInvalidArgument()
|
||||
{
|
||||
$this->coverage->setMapTestClassNameToCoveredClassName(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_CodeCoverage::clear
|
||||
*/
|
||||
public function testClear()
|
||||
{
|
||||
$this->coverage->clear();
|
||||
|
||||
$this->assertAttributeEquals(null, 'currentId', $this->coverage);
|
||||
$this->assertAttributeEquals(array(), 'data', $this->coverage);
|
||||
$this->assertAttributeEquals(array(), 'tests', $this->coverage);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_CodeCoverage::start
|
||||
* @covers PHP_CodeCoverage::stop
|
||||
* @covers PHP_CodeCoverage::append
|
||||
* @covers PHP_CodeCoverage::applyListsFilter
|
||||
* @covers PHP_CodeCoverage::initializeFilesThatAreSeenTheFirstTime
|
||||
* @covers PHP_CodeCoverage::applyCoversAnnotationFilter
|
||||
* @covers PHP_CodeCoverage::getTests
|
||||
*/
|
||||
public function testCollect()
|
||||
{
|
||||
$coverage = $this->getCoverageForBankAccount();
|
||||
|
||||
$this->assertEquals(
|
||||
$this->getExpectedDataArrayForBankAccount(),
|
||||
$coverage->getData()
|
||||
);
|
||||
|
||||
if (version_compare(PHPUnit_Runner_Version::id(), '4.7', '>=')) {
|
||||
$size = 'unknown';
|
||||
} else {
|
||||
$size = 'small';
|
||||
}
|
||||
|
||||
$this->assertEquals(
|
||||
array(
|
||||
'BankAccountTest::testBalanceIsInitiallyZero' => array('size' => $size, 'status' => null),
|
||||
'BankAccountTest::testBalanceCannotBecomeNegative' => array('size' => $size, 'status' => null),
|
||||
'BankAccountTest::testBalanceCannotBecomeNegative2' => array('size' => $size, 'status' => null),
|
||||
'BankAccountTest::testDepositWithdrawMoney' => array('size' => $size, 'status' => null)
|
||||
),
|
||||
$coverage->getTests()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_CodeCoverage::getData
|
||||
* @covers PHP_CodeCoverage::merge
|
||||
*/
|
||||
public function testMerge()
|
||||
{
|
||||
$coverage = $this->getCoverageForBankAccountForFirstTwoTests();
|
||||
$coverage->merge($this->getCoverageForBankAccountForLastTwoTests());
|
||||
|
||||
$this->assertEquals(
|
||||
$this->getExpectedDataArrayForBankAccount(),
|
||||
$coverage->getData()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_CodeCoverage::getData
|
||||
* @covers PHP_CodeCoverage::merge
|
||||
*/
|
||||
public function testMerge2()
|
||||
{
|
||||
$coverage = new PHP_CodeCoverage(
|
||||
$this->getMock('PHP_CodeCoverage_Driver_Xdebug'),
|
||||
new PHP_CodeCoverage_Filter
|
||||
);
|
||||
|
||||
$coverage->merge($this->getCoverageForBankAccount());
|
||||
|
||||
$this->assertEquals(
|
||||
$this->getExpectedDataArrayForBankAccount(),
|
||||
$coverage->getData()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_CodeCoverage::getLinesToBeIgnored
|
||||
*/
|
||||
public function testGetLinesToBeIgnored()
|
||||
{
|
||||
$this->assertEquals(
|
||||
array(
|
||||
1,
|
||||
3,
|
||||
4,
|
||||
5,
|
||||
7,
|
||||
8,
|
||||
9,
|
||||
10,
|
||||
11,
|
||||
12,
|
||||
13,
|
||||
14,
|
||||
15,
|
||||
16,
|
||||
17,
|
||||
18,
|
||||
19,
|
||||
20,
|
||||
21,
|
||||
22,
|
||||
23,
|
||||
24,
|
||||
25,
|
||||
26,
|
||||
27,
|
||||
28,
|
||||
30,
|
||||
32,
|
||||
33,
|
||||
34,
|
||||
35,
|
||||
36,
|
||||
37,
|
||||
38
|
||||
),
|
||||
$this->getLinesToBeIgnored()->invoke(
|
||||
$this->coverage,
|
||||
TEST_FILES_PATH . 'source_with_ignore.php'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_CodeCoverage::getLinesToBeIgnored
|
||||
*/
|
||||
public function testGetLinesToBeIgnored2()
|
||||
{
|
||||
$this->assertEquals(
|
||||
array(1, 5),
|
||||
$this->getLinesToBeIgnored()->invoke(
|
||||
$this->coverage,
|
||||
TEST_FILES_PATH . 'source_without_ignore.php'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_CodeCoverage::getLinesToBeIgnored
|
||||
*/
|
||||
public function testGetLinesToBeIgnored3()
|
||||
{
|
||||
$this->assertEquals(
|
||||
array(
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
4,
|
||||
5,
|
||||
8,
|
||||
11,
|
||||
15,
|
||||
16,
|
||||
19,
|
||||
20
|
||||
),
|
||||
$this->getLinesToBeIgnored()->invoke(
|
||||
$this->coverage,
|
||||
TEST_FILES_PATH . 'source_with_class_and_anonymous_function.php'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_CodeCoverage::getLinesToBeIgnored
|
||||
*/
|
||||
public function testGetLinesToBeIgnoredOneLineAnnotations()
|
||||
{
|
||||
$this->assertEquals(
|
||||
array(
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
4,
|
||||
5,
|
||||
6,
|
||||
7,
|
||||
8,
|
||||
9,
|
||||
10,
|
||||
11,
|
||||
12,
|
||||
13,
|
||||
14,
|
||||
15,
|
||||
16,
|
||||
18,
|
||||
20,
|
||||
21,
|
||||
23,
|
||||
24,
|
||||
25,
|
||||
27,
|
||||
28,
|
||||
29,
|
||||
30,
|
||||
31,
|
||||
32,
|
||||
33,
|
||||
34,
|
||||
37
|
||||
),
|
||||
$this->getLinesToBeIgnored()->invoke(
|
||||
$this->coverage,
|
||||
TEST_FILES_PATH . 'source_with_oneline_annotations.php'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ReflectionMethod
|
||||
*/
|
||||
private function getLinesToBeIgnored()
|
||||
{
|
||||
$getLinesToBeIgnored = new ReflectionMethod(
|
||||
'PHP_CodeCoverage',
|
||||
'getLinesToBeIgnored'
|
||||
);
|
||||
|
||||
$getLinesToBeIgnored->setAccessible(true);
|
||||
|
||||
return $getLinesToBeIgnored;
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_CodeCoverage::getLinesToBeIgnored
|
||||
*/
|
||||
public function testGetLinesToBeIgnoredWhenIgnoreIsDisabled()
|
||||
{
|
||||
$this->coverage->setDisableIgnoredLines(true);
|
||||
|
||||
$this->assertEquals(
|
||||
array(),
|
||||
$this->getLinesToBeIgnored()->invoke(
|
||||
$this->coverage,
|
||||
TEST_FILES_PATH . 'source_with_ignore.php'
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
311
vendor/phpunit/php-code-coverage/tests/TestCase.php
vendored
311
vendor/phpunit/php-code-coverage/tests/TestCase.php
vendored
|
@ -1,311 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the PHP_CodeCoverage package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Abstract base class for test case classes.
|
||||
*
|
||||
* @since Class available since Release 1.0.0
|
||||
*/
|
||||
abstract class PHP_CodeCoverage_TestCase extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected function getXdebugDataForBankAccount()
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
TEST_FILES_PATH . 'BankAccount.php' => array(
|
||||
8 => 1,
|
||||
9 => -2,
|
||||
13 => -1,
|
||||
14 => -1,
|
||||
15 => -1,
|
||||
16 => -1,
|
||||
18 => -1,
|
||||
22 => -1,
|
||||
24 => -1,
|
||||
25 => -2,
|
||||
29 => -1,
|
||||
31 => -1,
|
||||
32 => -2
|
||||
)
|
||||
),
|
||||
array(
|
||||
TEST_FILES_PATH . 'BankAccount.php' => array(
|
||||
8 => 1,
|
||||
13 => 1,
|
||||
16 => 1,
|
||||
29 => 1,
|
||||
)
|
||||
),
|
||||
array(
|
||||
TEST_FILES_PATH . 'BankAccount.php' => array(
|
||||
8 => 1,
|
||||
13 => 1,
|
||||
16 => 1,
|
||||
22 => 1,
|
||||
)
|
||||
),
|
||||
array(
|
||||
TEST_FILES_PATH . 'BankAccount.php' => array(
|
||||
8 => 1,
|
||||
13 => 1,
|
||||
14 => 1,
|
||||
15 => 1,
|
||||
18 => 1,
|
||||
22 => 1,
|
||||
24 => 1,
|
||||
29 => 1,
|
||||
31 => 1,
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
protected function getCoverageForBankAccount()
|
||||
{
|
||||
$data = $this->getXdebugDataForBankAccount();
|
||||
|
||||
$stub = $this->getMock('PHP_CodeCoverage_Driver_Xdebug');
|
||||
$stub->expects($this->any())
|
||||
->method('stop')
|
||||
->will($this->onConsecutiveCalls(
|
||||
$data[0],
|
||||
$data[1],
|
||||
$data[2],
|
||||
$data[3]
|
||||
));
|
||||
|
||||
$coverage = new PHP_CodeCoverage($stub, new PHP_CodeCoverage_Filter);
|
||||
|
||||
$coverage->start(
|
||||
new BankAccountTest('testBalanceIsInitiallyZero'),
|
||||
true
|
||||
);
|
||||
|
||||
$coverage->stop(
|
||||
true,
|
||||
array(TEST_FILES_PATH . 'BankAccount.php' => range(6, 9))
|
||||
);
|
||||
|
||||
$coverage->start(
|
||||
new BankAccountTest('testBalanceCannotBecomeNegative')
|
||||
);
|
||||
|
||||
$coverage->stop(
|
||||
true,
|
||||
array(TEST_FILES_PATH . 'BankAccount.php' => range(27, 32))
|
||||
);
|
||||
|
||||
$coverage->start(
|
||||
new BankAccountTest('testBalanceCannotBecomeNegative2')
|
||||
);
|
||||
|
||||
$coverage->stop(
|
||||
true,
|
||||
array(TEST_FILES_PATH . 'BankAccount.php' => range(20, 25))
|
||||
);
|
||||
|
||||
$coverage->start(
|
||||
new BankAccountTest('testDepositWithdrawMoney')
|
||||
);
|
||||
|
||||
$coverage->stop(
|
||||
true,
|
||||
array(
|
||||
TEST_FILES_PATH . 'BankAccount.php' => array_merge(
|
||||
range(6, 9),
|
||||
range(20, 25),
|
||||
range(27, 32)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
return $coverage;
|
||||
}
|
||||
|
||||
protected function getCoverageForBankAccountForFirstTwoTests()
|
||||
{
|
||||
$data = $this->getXdebugDataForBankAccount();
|
||||
|
||||
$stub = $this->getMock('PHP_CodeCoverage_Driver_Xdebug');
|
||||
$stub->expects($this->any())
|
||||
->method('stop')
|
||||
->will($this->onConsecutiveCalls(
|
||||
$data[0],
|
||||
$data[1]
|
||||
));
|
||||
|
||||
$coverage = new PHP_CodeCoverage($stub, new PHP_CodeCoverage_Filter);
|
||||
|
||||
$coverage->start(
|
||||
new BankAccountTest('testBalanceIsInitiallyZero'),
|
||||
true
|
||||
);
|
||||
|
||||
$coverage->stop(
|
||||
true,
|
||||
array(TEST_FILES_PATH . 'BankAccount.php' => range(6, 9))
|
||||
);
|
||||
|
||||
$coverage->start(
|
||||
new BankAccountTest('testBalanceCannotBecomeNegative')
|
||||
);
|
||||
|
||||
$coverage->stop(
|
||||
true,
|
||||
array(TEST_FILES_PATH . 'BankAccount.php' => range(27, 32))
|
||||
);
|
||||
|
||||
return $coverage;
|
||||
}
|
||||
|
||||
protected function getCoverageForBankAccountForLastTwoTests()
|
||||
{
|
||||
$data = $this->getXdebugDataForBankAccount();
|
||||
|
||||
$stub = $this->getMock('PHP_CodeCoverage_Driver_Xdebug');
|
||||
$stub->expects($this->any())
|
||||
->method('stop')
|
||||
->will($this->onConsecutiveCalls(
|
||||
$data[2],
|
||||
$data[3]
|
||||
));
|
||||
|
||||
$coverage = new PHP_CodeCoverage($stub, new PHP_CodeCoverage_Filter);
|
||||
|
||||
$coverage->start(
|
||||
new BankAccountTest('testBalanceCannotBecomeNegative2')
|
||||
);
|
||||
|
||||
$coverage->stop(
|
||||
true,
|
||||
array(TEST_FILES_PATH . 'BankAccount.php' => range(20, 25))
|
||||
);
|
||||
|
||||
$coverage->start(
|
||||
new BankAccountTest('testDepositWithdrawMoney')
|
||||
);
|
||||
|
||||
$coverage->stop(
|
||||
true,
|
||||
array(
|
||||
TEST_FILES_PATH . 'BankAccount.php' => array_merge(
|
||||
range(6, 9),
|
||||
range(20, 25),
|
||||
range(27, 32)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
return $coverage;
|
||||
}
|
||||
|
||||
protected function getExpectedDataArrayForBankAccount()
|
||||
{
|
||||
return array(
|
||||
TEST_FILES_PATH . 'BankAccount.php' => array(
|
||||
8 => array(
|
||||
0 => 'BankAccountTest::testBalanceIsInitiallyZero',
|
||||
1 => 'BankAccountTest::testDepositWithdrawMoney'
|
||||
),
|
||||
9 => null,
|
||||
13 => array(),
|
||||
14 => array(),
|
||||
15 => array(),
|
||||
16 => array(),
|
||||
18 => array(),
|
||||
22 => array(
|
||||
0 => 'BankAccountTest::testBalanceCannotBecomeNegative2',
|
||||
1 => 'BankAccountTest::testDepositWithdrawMoney'
|
||||
),
|
||||
24 => array(
|
||||
0 => 'BankAccountTest::testDepositWithdrawMoney',
|
||||
),
|
||||
25 => null,
|
||||
29 => array(
|
||||
0 => 'BankAccountTest::testBalanceCannotBecomeNegative',
|
||||
1 => 'BankAccountTest::testDepositWithdrawMoney'
|
||||
),
|
||||
31 => array(
|
||||
0 => 'BankAccountTest::testDepositWithdrawMoney'
|
||||
),
|
||||
32 => null
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
protected function getCoverageForFileWithIgnoredLines()
|
||||
{
|
||||
$coverage = new PHP_CodeCoverage(
|
||||
$this->setUpXdebugStubForFileWithIgnoredLines(),
|
||||
new PHP_CodeCoverage_Filter
|
||||
);
|
||||
|
||||
$coverage->start('FileWithIgnoredLines', true);
|
||||
$coverage->stop();
|
||||
|
||||
return $coverage;
|
||||
}
|
||||
|
||||
protected function setUpXdebugStubForFileWithIgnoredLines()
|
||||
{
|
||||
$stub = $this->getMock('PHP_CodeCoverage_Driver_Xdebug');
|
||||
$stub->expects($this->any())
|
||||
->method('stop')
|
||||
->will($this->returnValue(
|
||||
array(
|
||||
TEST_FILES_PATH . 'source_with_ignore.php' => array(
|
||||
2 => 1,
|
||||
4 => -1,
|
||||
6 => -1,
|
||||
7 => 1
|
||||
)
|
||||
)
|
||||
));
|
||||
|
||||
return $stub;
|
||||
}
|
||||
|
||||
protected function getCoverageForClassWithAnonymousFunction()
|
||||
{
|
||||
$coverage = new PHP_CodeCoverage(
|
||||
$this->setUpXdebugStubForClassWithAnonymousFunction(),
|
||||
new PHP_CodeCoverage_Filter
|
||||
);
|
||||
|
||||
$coverage->start('ClassWithAnonymousFunction', true);
|
||||
$coverage->stop();
|
||||
|
||||
return $coverage;
|
||||
}
|
||||
|
||||
protected function setUpXdebugStubForClassWithAnonymousFunction()
|
||||
{
|
||||
$stub = $this->getMock('PHP_CodeCoverage_Driver_Xdebug');
|
||||
$stub->expects($this->any())
|
||||
->method('stop')
|
||||
->will($this->returnValue(
|
||||
array(
|
||||
TEST_FILES_PATH . 'source_with_class_and_anonymous_function.php' => array(
|
||||
7 => 1,
|
||||
9 => 1,
|
||||
10 => -1,
|
||||
11 => 1,
|
||||
12 => 1,
|
||||
13 => 1,
|
||||
14 => 1,
|
||||
17 => 1,
|
||||
18 => 1
|
||||
)
|
||||
)
|
||||
));
|
||||
|
||||
return $stub;
|
||||
}
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<coverage generated="%i">
|
||||
<project timestamp="%i" name="BankAccount">
|
||||
<file name="%s/BankAccount.php">
|
||||
<class name="BankAccount" namespace="global">
|
||||
<metrics methods="4" coveredmethods="3" conditionals="0" coveredconditionals="0" statements="10" coveredstatements="5" elements="14" coveredelements="8"/>
|
||||
</class>
|
||||
<line num="6" type="method" name="getBalance" crap="1" count="2"/>
|
||||
<line num="8" type="stmt" count="2"/>
|
||||
<line num="11" type="method" name="setBalance" crap="6" count="0"/>
|
||||
<line num="13" type="stmt" count="0"/>
|
||||
<line num="14" type="stmt" count="0"/>
|
||||
<line num="15" type="stmt" count="0"/>
|
||||
<line num="16" type="stmt" count="0"/>
|
||||
<line num="18" type="stmt" count="0"/>
|
||||
<line num="20" type="method" name="depositMoney" crap="1" count="2"/>
|
||||
<line num="22" type="stmt" count="2"/>
|
||||
<line num="24" type="stmt" count="1"/>
|
||||
<line num="27" type="method" name="withdrawMoney" crap="1" count="2"/>
|
||||
<line num="29" type="stmt" count="2"/>
|
||||
<line num="31" type="stmt" count="1"/>
|
||||
<metrics loc="33" ncloc="33" classes="1" methods="4" coveredmethods="3" conditionals="0" coveredconditionals="0" statements="10" coveredstatements="5" elements="14" coveredelements="8"/>
|
||||
</file>
|
||||
<metrics files="1" loc="33" ncloc="33" classes="1" methods="4" coveredmethods="3" conditionals="0" coveredconditionals="0" statements="10" coveredstatements="5" elements="14" coveredelements="8"/>
|
||||
</project>
|
||||
</coverage>
|
|
@ -1,33 +0,0 @@
|
|||
<?php
|
||||
class BankAccount
|
||||
{
|
||||
protected $balance = 0;
|
||||
|
||||
public function getBalance()
|
||||
{
|
||||
return $this->balance;
|
||||
}
|
||||
|
||||
protected function setBalance($balance)
|
||||
{
|
||||
if ($balance >= 0) {
|
||||
$this->balance = $balance;
|
||||
} else {
|
||||
throw new RuntimeException;
|
||||
}
|
||||
}
|
||||
|
||||
public function depositMoney($balance)
|
||||
{
|
||||
$this->setBalance($this->getBalance() + $balance);
|
||||
|
||||
return $this->getBalance();
|
||||
}
|
||||
|
||||
public function withdrawMoney($balance)
|
||||
{
|
||||
$this->setBalance($this->getBalance() - $balance);
|
||||
|
||||
return $this->getBalance();
|
||||
}
|
||||
}
|
|
@ -1,66 +0,0 @@
|
|||
<?php
|
||||
require_once 'BankAccount.php';
|
||||
|
||||
class BankAccountTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected $ba;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->ba = new BankAccount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers BankAccount::getBalance
|
||||
*/
|
||||
public function testBalanceIsInitiallyZero()
|
||||
{
|
||||
$this->assertEquals(0, $this->ba->getBalance());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers BankAccount::withdrawMoney
|
||||
*/
|
||||
public function testBalanceCannotBecomeNegative()
|
||||
{
|
||||
try {
|
||||
$this->ba->withdrawMoney(1);
|
||||
} catch (RuntimeException $e) {
|
||||
$this->assertEquals(0, $this->ba->getBalance());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->fail();
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers BankAccount::depositMoney
|
||||
*/
|
||||
public function testBalanceCannotBecomeNegative2()
|
||||
{
|
||||
try {
|
||||
$this->ba->depositMoney(-1);
|
||||
} catch (RuntimeException $e) {
|
||||
$this->assertEquals(0, $this->ba->getBalance());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->fail();
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers BankAccount::getBalance
|
||||
* @covers BankAccount::depositMoney
|
||||
* @covers BankAccount::withdrawMoney
|
||||
*/
|
||||
public function testDepositWithdrawMoney()
|
||||
{
|
||||
$this->assertEquals(0, $this->ba->getBalance());
|
||||
$this->ba->depositMoney(1);
|
||||
$this->assertEquals(1, $this->ba->getBalance());
|
||||
$this->ba->withdrawMoney(1);
|
||||
$this->assertEquals(0, $this->ba->getBalance());
|
||||
}
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
<?php
|
||||
class CoverageClassExtendedTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @covers CoveredClass<extended>
|
||||
*/
|
||||
public function testSomething()
|
||||
{
|
||||
$o = new CoveredClass;
|
||||
$o->publicMethod();
|
||||
}
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
<?php
|
||||
class CoverageClassTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @covers CoveredClass
|
||||
*/
|
||||
public function testSomething()
|
||||
{
|
||||
$o = new CoveredClass;
|
||||
$o->publicMethod();
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
<?php
|
||||
class CoverageFunctionParenthesesTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @covers ::globalFunction()
|
||||
*/
|
||||
public function testSomething()
|
||||
{
|
||||
globalFunction();
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
<?php
|
||||
class CoverageFunctionParenthesesWhitespaceTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @covers ::globalFunction ( )
|
||||
*/
|
||||
public function testSomething()
|
||||
{
|
||||
globalFunction();
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
<?php
|
||||
class CoverageFunctionTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @covers ::globalFunction
|
||||
*/
|
||||
public function testSomething()
|
||||
{
|
||||
globalFunction();
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
<?php
|
||||
|
||||
class CoverageMethodOneLineAnnotationTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/** @covers CoveredClass::publicMethod */
|
||||
public function testSomething()
|
||||
{
|
||||
$o = new CoveredClass;
|
||||
$o->publicMethod();
|
||||
}
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
<?php
|
||||
class CoverageMethodParenthesesTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @covers CoveredClass::publicMethod()
|
||||
*/
|
||||
public function testSomething()
|
||||
{
|
||||
$o = new CoveredClass;
|
||||
$o->publicMethod();
|
||||
}
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
<?php
|
||||
class CoverageMethodParenthesesWhitespaceTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @covers CoveredClass::publicMethod ( )
|
||||
*/
|
||||
public function testSomething()
|
||||
{
|
||||
$o = new CoveredClass;
|
||||
$o->publicMethod();
|
||||
}
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
<?php
|
||||
class CoverageMethodTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @covers CoveredClass::publicMethod
|
||||
*/
|
||||
public function testSomething()
|
||||
{
|
||||
$o = new CoveredClass;
|
||||
$o->publicMethod();
|
||||
}
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
<?php
|
||||
class CoverageNoneTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testSomething()
|
||||
{
|
||||
$o = new CoveredClass;
|
||||
$o->publicMethod();
|
||||
}
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
<?php
|
||||
class CoverageNotPrivateTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @covers CoveredClass::<!private>
|
||||
*/
|
||||
public function testSomething()
|
||||
{
|
||||
$o = new CoveredClass;
|
||||
$o->publicMethod();
|
||||
}
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
<?php
|
||||
class CoverageNotProtectedTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @covers CoveredClass::<!protected>
|
||||
*/
|
||||
public function testSomething()
|
||||
{
|
||||
$o = new CoveredClass;
|
||||
$o->publicMethod();
|
||||
}
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
<?php
|
||||
class CoverageNotPublicTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @covers CoveredClass::<!public>
|
||||
*/
|
||||
public function testSomething()
|
||||
{
|
||||
$o = new CoveredClass;
|
||||
$o->publicMethod();
|
||||
}
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
<?php
|
||||
class CoverageNothingTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @covers CoveredClass::publicMethod
|
||||
* @coversNothing
|
||||
*/
|
||||
public function testSomething()
|
||||
{
|
||||
$o = new CoveredClass;
|
||||
$o->publicMethod();
|
||||
}
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
<?php
|
||||
class CoveragePrivateTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @covers CoveredClass::<private>
|
||||
*/
|
||||
public function testSomething()
|
||||
{
|
||||
$o = new CoveredClass;
|
||||
$o->publicMethod();
|
||||
}
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
<?php
|
||||
class CoverageProtectedTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @covers CoveredClass::<protected>
|
||||
*/
|
||||
public function testSomething()
|
||||
{
|
||||
$o = new CoveredClass;
|
||||
$o->publicMethod();
|
||||
}
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
<?php
|
||||
class CoveragePublicTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @covers CoveredClass::<public>
|
||||
*/
|
||||
public function testSomething()
|
||||
{
|
||||
$o = new CoveredClass;
|
||||
$o->publicMethod();
|
||||
}
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \NamespaceOne
|
||||
* @coversDefaultClass \AnotherDefault\Name\Space\Does\Not\Work
|
||||
*/
|
||||
class CoverageTwoDefaultClassAnnotations
|
||||
{
|
||||
/**
|
||||
* @covers Foo\CoveredClass::<public>
|
||||
*/
|
||||
public function testSomething()
|
||||
{
|
||||
$o = new Foo\CoveredClass;
|
||||
$o->publicMethod();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
<?php
|
||||
class CoveredParentClass
|
||||
{
|
||||
private function privateMethod()
|
||||
{
|
||||
}
|
||||
|
||||
protected function protectedMethod()
|
||||
{
|
||||
$this->privateMethod();
|
||||
}
|
||||
|
||||
public function publicMethod()
|
||||
{
|
||||
$this->protectedMethod();
|
||||
}
|
||||
}
|
||||
|
||||
class CoveredClass extends CoveredParentClass
|
||||
{
|
||||
private function privateMethod()
|
||||
{
|
||||
}
|
||||
|
||||
protected function protectedMethod()
|
||||
{
|
||||
parent::protectedMethod();
|
||||
$this->privateMethod();
|
||||
}
|
||||
|
||||
public function publicMethod()
|
||||
{
|
||||
parent::publicMethod();
|
||||
$this->protectedMethod();
|
||||
}
|
||||
}
|
|
@ -1,4 +0,0 @@
|
|||
<?php
|
||||
function globalFunction()
|
||||
{
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
<?php
|
||||
class NamespaceCoverageClassExtendedTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @covers Foo\CoveredClass<extended>
|
||||
*/
|
||||
public function testSomething()
|
||||
{
|
||||
$o = new Foo\CoveredClass;
|
||||
$o->publicMethod();
|
||||
}
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
<?php
|
||||
class NamespaceCoverageClassTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @covers Foo\CoveredClass
|
||||
*/
|
||||
public function testSomething()
|
||||
{
|
||||
$o = new Foo\CoveredClass;
|
||||
$o->publicMethod();
|
||||
}
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @coversDefaultClass \Foo\CoveredClass
|
||||
*/
|
||||
class NamespaceCoverageCoversClassPublicTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @covers ::publicMethod
|
||||
*/
|
||||
public function testSomething()
|
||||
{
|
||||
$o = new Foo\CoveredClass;
|
||||
$o->publicMethod();
|
||||
}
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @coversDefaultClass \Foo\CoveredClass
|
||||
*/
|
||||
class NamespaceCoverageCoversClassTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @covers ::privateMethod
|
||||
* @covers ::protectedMethod
|
||||
* @covers ::publicMethod
|
||||
* @covers \Foo\CoveredParentClass::privateMethod
|
||||
* @covers \Foo\CoveredParentClass::protectedMethod
|
||||
* @covers \Foo\CoveredParentClass::publicMethod
|
||||
*/
|
||||
public function testSomething()
|
||||
{
|
||||
$o = new Foo\CoveredClass;
|
||||
$o->publicMethod();
|
||||
}
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
<?php
|
||||
class NamespaceCoverageMethodTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @covers Foo\CoveredClass::publicMethod
|
||||
*/
|
||||
public function testSomething()
|
||||
{
|
||||
$o = new Foo\CoveredClass;
|
||||
$o->publicMethod();
|
||||
}
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
<?php
|
||||
class NamespaceCoverageNotPrivateTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @covers Foo\CoveredClass::<!private>
|
||||
*/
|
||||
public function testSomething()
|
||||
{
|
||||
$o = new Foo\CoveredClass;
|
||||
$o->publicMethod();
|
||||
}
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
<?php
|
||||
class NamespaceCoverageNotProtectedTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @covers Foo\CoveredClass::<!protected>
|
||||
*/
|
||||
public function testSomething()
|
||||
{
|
||||
$o = new Foo\CoveredClass;
|
||||
$o->publicMethod();
|
||||
}
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
<?php
|
||||
class NamespaceCoverageNotPublicTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @covers Foo\CoveredClass::<!public>
|
||||
*/
|
||||
public function testSomething()
|
||||
{
|
||||
$o = new Foo\CoveredClass;
|
||||
$o->publicMethod();
|
||||
}
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
<?php
|
||||
class NamespaceCoveragePrivateTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @covers Foo\CoveredClass::<private>
|
||||
*/
|
||||
public function testSomething()
|
||||
{
|
||||
$o = new Foo\CoveredClass;
|
||||
$o->publicMethod();
|
||||
}
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
<?php
|
||||
class NamespaceCoverageProtectedTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @covers Foo\CoveredClass::<protected>
|
||||
*/
|
||||
public function testSomething()
|
||||
{
|
||||
$o = new Foo\CoveredClass;
|
||||
$o->publicMethod();
|
||||
}
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
<?php
|
||||
class NamespaceCoveragePublicTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @covers Foo\CoveredClass::<public>
|
||||
*/
|
||||
public function testSomething()
|
||||
{
|
||||
$o = new Foo\CoveredClass;
|
||||
$o->publicMethod();
|
||||
}
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
<?php
|
||||
namespace Foo;
|
||||
|
||||
class CoveredParentClass
|
||||
{
|
||||
private function privateMethod()
|
||||
{
|
||||
}
|
||||
|
||||
protected function protectedMethod()
|
||||
{
|
||||
$this->privateMethod();
|
||||
}
|
||||
|
||||
public function publicMethod()
|
||||
{
|
||||
$this->protectedMethod();
|
||||
}
|
||||
}
|
||||
|
||||
class CoveredClass extends CoveredParentClass
|
||||
{
|
||||
private function privateMethod()
|
||||
{
|
||||
}
|
||||
|
||||
protected function protectedMethod()
|
||||
{
|
||||
parent::protectedMethod();
|
||||
$this->privateMethod();
|
||||
}
|
||||
|
||||
public function publicMethod()
|
||||
{
|
||||
parent::publicMethod();
|
||||
$this->protectedMethod();
|
||||
}
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
<?php
|
||||
class NotExistingCoveredElementTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @covers NotExistingClass
|
||||
*/
|
||||
public function testOne()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers NotExistingClass::notExistingMethod
|
||||
*/
|
||||
public function testTwo()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers NotExistingClass::<public>
|
||||
*/
|
||||
public function testThree()
|
||||
{
|
||||
}
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<coverage generated="%i">
|
||||
<project timestamp="%i">
|
||||
<file name="%s/source_with_class_and_anonymous_function.php">
|
||||
<class name="CoveredClassWithAnonymousFunctionInStaticMethod" namespace="global">
|
||||
<metrics methods="2" coveredmethods="1" conditionals="0" coveredconditionals="0" statements="5" coveredstatements="4" elements="7" coveredelements="5"/>
|
||||
</class>
|
||||
<line num="5" type="method" name="runAnonymous" crap="1.04" count="1"/>
|
||||
<line num="7" type="stmt" count="1"/>
|
||||
<line num="9" type="stmt" count="1"/>
|
||||
<line num="10" type="stmt" count="0"/>
|
||||
<line num="11" type="method" name="anonymous function" crap="1" count="1"/>
|
||||
<line num="12" type="stmt" count="1"/>
|
||||
<line num="13" type="stmt" count="1"/>
|
||||
<line num="14" type="stmt" count="1"/>
|
||||
<line num="17" type="stmt" count="1"/>
|
||||
<line num="18" type="stmt" count="1"/>
|
||||
<metrics loc="19" ncloc="17" classes="1" methods="2" coveredmethods="1" conditionals="0" coveredconditionals="0" statements="8" coveredstatements="7" elements="10" coveredelements="8"/>
|
||||
</file>
|
||||
<metrics files="1" loc="19" ncloc="17" classes="1" methods="2" coveredmethods="1" conditionals="0" coveredconditionals="0" statements="8" coveredstatements="7" elements="10" coveredelements="8"/>
|
||||
</project>
|
||||
</coverage>
|
|
@ -1,17 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<coverage generated="%i">
|
||||
<project timestamp="%i">
|
||||
<file name="%s/source_with_ignore.php">
|
||||
<class name="Foo" namespace="global">
|
||||
<metrics methods="0" coveredmethods="0" conditionals="0" coveredconditionals="0" statements="0" coveredstatements="0" elements="0" coveredelements="0"/>
|
||||
</class>
|
||||
<class name="Bar" namespace="global">
|
||||
<metrics methods="0" coveredmethods="0" conditionals="0" coveredconditionals="0" statements="0" coveredstatements="0" elements="0" coveredelements="0"/>
|
||||
</class>
|
||||
<line num="2" type="stmt" count="1"/>
|
||||
<line num="6" type="stmt" count="0"/>
|
||||
<metrics loc="37" ncloc="25" classes="2" methods="0" coveredmethods="0" conditionals="0" coveredconditionals="0" statements="2" coveredstatements="1" elements="2" coveredelements="1"/>
|
||||
</file>
|
||||
<metrics files="1" loc="37" ncloc="25" classes="2" methods="0" coveredmethods="0" conditionals="0" coveredconditionals="0" statements="2" coveredstatements="1" elements="2" coveredelements="1"/>
|
||||
</project>
|
||||
</coverage>
|
|
@ -1,19 +0,0 @@
|
|||
<?php
|
||||
|
||||
class CoveredClassWithAnonymousFunctionInStaticMethod
|
||||
{
|
||||
public static function runAnonymous()
|
||||
{
|
||||
$filter = array('abc124', 'abc123', '123');
|
||||
|
||||
array_walk(
|
||||
$filter,
|
||||
function (&$val, $key) {
|
||||
$val = preg_replace('|[^0-9]|', '', $val);
|
||||
}
|
||||
);
|
||||
|
||||
// Should be covered
|
||||
$extravar = true;
|
||||
}
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
<?php
|
||||
if ($neverHappens) {
|
||||
// @codeCoverageIgnoreStart
|
||||
print '*';
|
||||
// @codeCoverageIgnoreEnd
|
||||
}
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
class Foo
|
||||
{
|
||||
public function bar()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
class Bar
|
||||
{
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function foo()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
function baz()
|
||||
{
|
||||
print '*'; // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
interface Bor
|
||||
{
|
||||
public function foo();
|
||||
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
<?php
|
||||
namespace bar\baz;
|
||||
|
||||
/**
|
||||
* Represents foo.
|
||||
*/
|
||||
class source_with_namespace
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $bar
|
||||
*/
|
||||
function &foo($bar)
|
||||
{
|
||||
$baz = function () {};
|
||||
$a = true ? true : false;
|
||||
$b = "{$a}";
|
||||
$c = "${b}";
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
<?php
|
||||
|
||||
/** Docblock */
|
||||
interface Foo
|
||||
{
|
||||
public function bar();
|
||||
}
|
||||
|
||||
class Foo
|
||||
{
|
||||
public function bar()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
function baz()
|
||||
{
|
||||
// a one-line comment
|
||||
print '*'; // a one-line comment
|
||||
|
||||
/* a one-line comment */
|
||||
print '*'; /* a one-line comment */
|
||||
|
||||
/* a one-line comment
|
||||
*/
|
||||
print '*'; /* a one-line comment
|
||||
*/
|
||||
|
||||
print '*'; // @codeCoverageIgnore
|
||||
|
||||
print '*'; // @codeCoverageIgnoreStart
|
||||
print '*';
|
||||
print '*'; // @codeCoverageIgnoreEnd
|
||||
|
||||
print '*';
|
||||
}
|
|
@ -1,4 +0,0 @@
|
|||
<?php
|
||||
if ($neverHappens) {
|
||||
print '*';
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Represents foo.
|
||||
*/
|
||||
class Foo
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $bar
|
||||
*/
|
||||
function &foo($bar)
|
||||
{
|
||||
$baz = function () {};
|
||||
$a = true ? true : false;
|
||||
$b = "{$a}";
|
||||
$c = "${b}";
|
||||
}
|
101
vendor/phpunit/php-timer/Tests/TimerTest.php
vendored
101
vendor/phpunit/php-timer/Tests/TimerTest.php
vendored
|
@ -1,101 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the PHP_Timer package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Tests for PHP_Timer.
|
||||
*
|
||||
* @since Class available since Release 1.0.0
|
||||
*/
|
||||
class PHP_TimerTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @covers PHP_Timer::start
|
||||
* @covers PHP_Timer::stop
|
||||
*/
|
||||
public function testStartStop()
|
||||
{
|
||||
$this->assertInternalType('float', PHP_Timer::stop());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_Timer::secondsToTimeString
|
||||
* @dataProvider secondsProvider
|
||||
*/
|
||||
public function testSecondsToTimeString($string, $seconds)
|
||||
{
|
||||
$this->assertEquals(
|
||||
$string,
|
||||
PHP_Timer::secondsToTimeString($seconds)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_Timer::timeSinceStartOfRequest
|
||||
*/
|
||||
public function testTimeSinceStartOfRequest()
|
||||
{
|
||||
$this->assertStringMatchesFormat(
|
||||
'%f %s',
|
||||
PHP_Timer::timeSinceStartOfRequest()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @covers PHP_Timer::resourceUsage
|
||||
*/
|
||||
public function testResourceUsage()
|
||||
{
|
||||
$this->assertStringMatchesFormat(
|
||||
'Time: %s, Memory: %s',
|
||||
PHP_Timer::resourceUsage()
|
||||
);
|
||||
}
|
||||
|
||||
public function secondsProvider()
|
||||
{
|
||||
return array(
|
||||
array('0 ms', 0),
|
||||
array('1 ms', .001),
|
||||
array('10 ms', .01),
|
||||
array('100 ms', .1),
|
||||
array('999 ms', .999),
|
||||
array('1 second', .9999),
|
||||
array('1 second', 1),
|
||||
array('2 seconds', 2),
|
||||
array('59.9 seconds', 59.9),
|
||||
array('59.99 seconds', 59.99),
|
||||
array('59.99 seconds', 59.999),
|
||||
array('1 minute', 59.9999),
|
||||
array('59 seconds', 59.001),
|
||||
array('59.01 seconds', 59.01),
|
||||
array('1 minute', 60),
|
||||
array('1.01 minutes', 61),
|
||||
array('2 minutes', 120),
|
||||
array('2.01 minutes', 121),
|
||||
array('59.99 minutes', 3599.9),
|
||||
array('59.99 minutes', 3599.99),
|
||||
array('59.99 minutes', 3599.999),
|
||||
array('1 hour', 3599.9999),
|
||||
array('59.98 minutes', 3599.001),
|
||||
array('59.98 minutes', 3599.01),
|
||||
array('1 hour', 3600),
|
||||
array('1 hour', 3601),
|
||||
array('1 hour', 3601.9),
|
||||
array('1 hour', 3601.99),
|
||||
array('1 hour', 3601.999),
|
||||
array('1 hour', 3601.9999),
|
||||
array('1.01 hours', 3659.9999),
|
||||
array('1.01 hours', 3659.001),
|
||||
array('1.01 hours', 3659.01),
|
||||
array('2 hours', 7199.9999),
|
||||
);
|
||||
}
|
||||
}
|
|
@ -1,112 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the PHP_TokenStream package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Tests for the PHP_Token_CLASS class.
|
||||
*
|
||||
* @package PHP_TokenStream
|
||||
* @subpackage Tests
|
||||
* @author Laurent Laville <pear@laurent-laville.org>
|
||||
* @copyright Sebastian Bergmann <sebastian@phpunit.de>
|
||||
* @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License
|
||||
* @version Release: @package_version@
|
||||
* @link http://github.com/sebastianbergmann/php-token-stream/
|
||||
* @since Class available since Release 1.0.2
|
||||
*/
|
||||
class PHP_Token_ClassTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected $class;
|
||||
protected $function;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$ts = new PHP_Token_Stream(TEST_FILES_PATH . 'source2.php');
|
||||
|
||||
foreach ($ts as $token) {
|
||||
if ($token instanceof PHP_Token_CLASS) {
|
||||
$this->class = $token;
|
||||
}
|
||||
|
||||
if ($token instanceof PHP_Token_FUNCTION) {
|
||||
$this->function = $token;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_Token_CLASS::getKeywords
|
||||
*/
|
||||
public function testGetClassKeywords()
|
||||
{
|
||||
$this->assertEquals('abstract', $this->class->getKeywords());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_Token_FUNCTION::getKeywords
|
||||
*/
|
||||
public function testGetFunctionKeywords()
|
||||
{
|
||||
$this->assertEquals('abstract,static', $this->function->getKeywords());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_Token_FUNCTION::getVisibility
|
||||
*/
|
||||
public function testGetFunctionVisibility()
|
||||
{
|
||||
$this->assertEquals('public', $this->function->getVisibility());
|
||||
}
|
||||
|
||||
public function testIssue19()
|
||||
{
|
||||
$ts = new PHP_Token_Stream(TEST_FILES_PATH . 'issue19.php');
|
||||
|
||||
foreach ($ts as $token) {
|
||||
if ($token instanceof PHP_Token_CLASS) {
|
||||
$this->assertFalse($token->hasInterfaces());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function testIssue30()
|
||||
{
|
||||
$ts = new PHP_Token_Stream(TEST_FILES_PATH . 'issue30.php');
|
||||
$this->assertCount(1, $ts->getClasses());
|
||||
}
|
||||
|
||||
/**
|
||||
* @requires PHP 7
|
||||
*/
|
||||
public function testAnonymousClassesAreHandledCorrectly()
|
||||
{
|
||||
$ts = new PHP_Token_Stream(TEST_FILES_PATH . 'class_with_method_that_declares_anonymous_class.php');
|
||||
|
||||
$classes = $ts->getClasses();
|
||||
|
||||
$this->assertEquals(array('class_with_method_that_declares_anonymous_class'), array_keys($classes));
|
||||
}
|
||||
|
||||
/**
|
||||
* @requires PHP 7
|
||||
* @ticket https://github.com/sebastianbergmann/php-token-stream/issues/52
|
||||
*/
|
||||
public function testAnonymousClassesAreHandledCorrectly2()
|
||||
{
|
||||
$ts = new PHP_Token_Stream(TEST_FILES_PATH . 'class_with_method_that_declares_anonymous_class2.php');
|
||||
|
||||
$classes = $ts->getClasses();
|
||||
|
||||
$this->assertEquals(array('Test'), array_keys($classes));
|
||||
$this->assertEquals(array('methodOne', 'methodTwo'), array_keys($classes['Test']['methods']));
|
||||
|
||||
$this->assertEmpty($ts->getFunctions());
|
||||
}
|
||||
}
|
|
@ -1,85 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the PHP_TokenStream package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Tests for the PHP_Token_FUNCTION class.
|
||||
*
|
||||
* @package PHP_TokenStream
|
||||
* @subpackage Tests
|
||||
* @author Sebastian Bergmann <sebastian@phpunit.de>
|
||||
* @copyright Sebastian Bergmann <sebastian@phpunit.de>
|
||||
* @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License
|
||||
* @version Release: @package_version@
|
||||
* @link http://github.com/sebastianbergmann/php-token-stream/
|
||||
* @since Class available since Release 1.0.0
|
||||
*/
|
||||
class PHP_Token_ClosureTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected $functions;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$ts = new PHP_Token_Stream(TEST_FILES_PATH . 'closure.php');
|
||||
|
||||
foreach ($ts as $token) {
|
||||
if ($token instanceof PHP_Token_FUNCTION) {
|
||||
$this->functions[] = $token;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_Token_FUNCTION::getArguments
|
||||
*/
|
||||
public function testGetArguments()
|
||||
{
|
||||
$this->assertEquals(array('$foo' => null, '$bar' => null), $this->functions[0]->getArguments());
|
||||
$this->assertEquals(array('$foo' => 'Foo', '$bar' => null), $this->functions[1]->getArguments());
|
||||
$this->assertEquals(array('$foo' => null, '$bar' => null, '$baz' => null), $this->functions[2]->getArguments());
|
||||
$this->assertEquals(array('$foo' => 'Foo', '$bar' => null, '$baz' => null), $this->functions[3]->getArguments());
|
||||
$this->assertEquals(array(), $this->functions[4]->getArguments());
|
||||
$this->assertEquals(array(), $this->functions[5]->getArguments());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_Token_FUNCTION::getName
|
||||
*/
|
||||
public function testGetName()
|
||||
{
|
||||
$this->assertEquals('anonymous function', $this->functions[0]->getName());
|
||||
$this->assertEquals('anonymous function', $this->functions[1]->getName());
|
||||
$this->assertEquals('anonymous function', $this->functions[2]->getName());
|
||||
$this->assertEquals('anonymous function', $this->functions[3]->getName());
|
||||
$this->assertEquals('anonymous function', $this->functions[4]->getName());
|
||||
$this->assertEquals('anonymous function', $this->functions[5]->getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_Token::getLine
|
||||
*/
|
||||
public function testGetLine()
|
||||
{
|
||||
$this->assertEquals(2, $this->functions[0]->getLine());
|
||||
$this->assertEquals(3, $this->functions[1]->getLine());
|
||||
$this->assertEquals(4, $this->functions[2]->getLine());
|
||||
$this->assertEquals(5, $this->functions[3]->getLine());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_TokenWithScope::getEndLine
|
||||
*/
|
||||
public function testGetEndLine()
|
||||
{
|
||||
$this->assertEquals(2, $this->functions[0]->getLine());
|
||||
$this->assertEquals(3, $this->functions[1]->getLine());
|
||||
$this->assertEquals(4, $this->functions[2]->getLine());
|
||||
$this->assertEquals(5, $this->functions[3]->getLine());
|
||||
}
|
||||
}
|
|
@ -1,146 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the PHP_TokenStream package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Tests for the PHP_Token_FUNCTION class.
|
||||
*
|
||||
* @package PHP_TokenStream
|
||||
* @subpackage Tests
|
||||
* @author Sebastian Bergmann <sebastian@phpunit.de>
|
||||
* @copyright Sebastian Bergmann <sebastian@phpunit.de>
|
||||
* @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License
|
||||
* @version Release: @package_version@
|
||||
* @link http://github.com/sebastianbergmann/php-token-stream/
|
||||
* @since Class available since Release 1.0.0
|
||||
*/
|
||||
class PHP_Token_FunctionTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected $functions;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$ts = new PHP_Token_Stream(TEST_FILES_PATH . 'source.php');
|
||||
|
||||
foreach ($ts as $token) {
|
||||
if ($token instanceof PHP_Token_FUNCTION) {
|
||||
$this->functions[] = $token;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_Token_FUNCTION::getArguments
|
||||
*/
|
||||
public function testGetArguments()
|
||||
{
|
||||
$this->assertEquals(array(), $this->functions[0]->getArguments());
|
||||
|
||||
$this->assertEquals(
|
||||
array('$baz' => 'Baz'), $this->functions[1]->getArguments()
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
array('$foobar' => 'Foobar'), $this->functions[2]->getArguments()
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
array('$barfoo' => 'Barfoo'), $this->functions[3]->getArguments()
|
||||
);
|
||||
|
||||
$this->assertEquals(array(), $this->functions[4]->getArguments());
|
||||
|
||||
$this->assertEquals(array('$x' => null, '$y' => null), $this->functions[5]->getArguments());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_Token_FUNCTION::getName
|
||||
*/
|
||||
public function testGetName()
|
||||
{
|
||||
$this->assertEquals('foo', $this->functions[0]->getName());
|
||||
$this->assertEquals('bar', $this->functions[1]->getName());
|
||||
$this->assertEquals('foobar', $this->functions[2]->getName());
|
||||
$this->assertEquals('barfoo', $this->functions[3]->getName());
|
||||
$this->assertEquals('baz', $this->functions[4]->getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_Token::getLine
|
||||
*/
|
||||
public function testGetLine()
|
||||
{
|
||||
$this->assertEquals(5, $this->functions[0]->getLine());
|
||||
$this->assertEquals(10, $this->functions[1]->getLine());
|
||||
$this->assertEquals(17, $this->functions[2]->getLine());
|
||||
$this->assertEquals(21, $this->functions[3]->getLine());
|
||||
$this->assertEquals(29, $this->functions[4]->getLine());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_TokenWithScope::getEndLine
|
||||
*/
|
||||
public function testGetEndLine()
|
||||
{
|
||||
$this->assertEquals(5, $this->functions[0]->getEndLine());
|
||||
$this->assertEquals(12, $this->functions[1]->getEndLine());
|
||||
$this->assertEquals(19, $this->functions[2]->getEndLine());
|
||||
$this->assertEquals(23, $this->functions[3]->getEndLine());
|
||||
$this->assertEquals(31, $this->functions[4]->getEndLine());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_Token_FUNCTION::getDocblock
|
||||
*/
|
||||
public function testGetDocblock()
|
||||
{
|
||||
$this->assertNull($this->functions[0]->getDocblock());
|
||||
|
||||
$this->assertEquals(
|
||||
"/**\n * @param Baz \$baz\n */",
|
||||
$this->functions[1]->getDocblock()
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
"/**\n * @param Foobar \$foobar\n */",
|
||||
$this->functions[2]->getDocblock()
|
||||
);
|
||||
|
||||
$this->assertNull($this->functions[3]->getDocblock());
|
||||
$this->assertNull($this->functions[4]->getDocblock());
|
||||
}
|
||||
|
||||
public function testSignature()
|
||||
{
|
||||
$ts = new PHP_Token_Stream(TEST_FILES_PATH . 'source5.php');
|
||||
$f = $ts->getFunctions();
|
||||
$c = $ts->getClasses();
|
||||
$i = $ts->getInterfaces();
|
||||
|
||||
$this->assertEquals(
|
||||
'foo($a, array $b, array $c = array())',
|
||||
$f['foo']['signature']
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
'm($a, array $b, array $c = array())',
|
||||
$c['c']['methods']['m']['signature']
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
'm($a, array $b, array $c = array())',
|
||||
$c['a']['methods']['m']['signature']
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
'm($a, array $b, array $c = array())',
|
||||
$i['i']['methods']['m']['signature']
|
||||
);
|
||||
}
|
||||
}
|
|
@ -1,73 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the PHP_TokenStream package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Tests for the PHP_Token_REQUIRE_ONCE, PHP_Token_REQUIRE
|
||||
* PHP_Token_INCLUDE_ONCE and PHP_Token_INCLUDE_ONCE classes.
|
||||
*
|
||||
* @package PHP_TokenStream
|
||||
* @subpackage Tests
|
||||
* @author Laurent Laville <pear@laurent-laville.org>
|
||||
* @copyright Sebastian Bergmann <sebastian@phpunit.de>
|
||||
* @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License
|
||||
* @version Release: @package_version@
|
||||
* @link http://github.com/sebastianbergmann/php-token-stream/
|
||||
* @since Class available since Release 1.0.2
|
||||
*/
|
||||
class PHP_Token_IncludeTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected $ts;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->ts = new PHP_Token_Stream(TEST_FILES_PATH . 'source3.php');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_Token_Includes::getName
|
||||
* @covers PHP_Token_Includes::getType
|
||||
*/
|
||||
public function testGetIncludes()
|
||||
{
|
||||
$this->assertSame(
|
||||
array('test4.php', 'test3.php', 'test2.php', 'test1.php'),
|
||||
$this->ts->getIncludes()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_Token_Includes::getName
|
||||
* @covers PHP_Token_Includes::getType
|
||||
*/
|
||||
public function testGetIncludesCategorized()
|
||||
{
|
||||
$this->assertSame(
|
||||
array(
|
||||
'require_once' => array('test4.php'),
|
||||
'require' => array('test3.php'),
|
||||
'include_once' => array('test2.php'),
|
||||
'include' => array('test1.php')
|
||||
),
|
||||
$this->ts->getIncludes(TRUE)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_Token_Includes::getName
|
||||
* @covers PHP_Token_Includes::getType
|
||||
*/
|
||||
public function testGetIncludesCategory()
|
||||
{
|
||||
$this->assertSame(
|
||||
array('test4.php'),
|
||||
$this->ts->getIncludes(TRUE, 'require_once')
|
||||
);
|
||||
}
|
||||
}
|
|
@ -1,191 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the PHP_TokenStream package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Tests for the PHP_Token_INTERFACE class.
|
||||
*
|
||||
* @package PHP_TokenStream
|
||||
* @subpackage Tests
|
||||
* @author Sebastian Bergmann <sebastian@phpunit.de>
|
||||
* @author Laurent Laville <pear@laurent-laville.org>
|
||||
* @copyright Sebastian Bergmann <sebastian@phpunit.de>
|
||||
* @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License
|
||||
* @version Release: @package_version@
|
||||
* @link http://github.com/sebastianbergmann/php-token-stream/
|
||||
* @since Class available since Release 1.0.0
|
||||
*/
|
||||
class PHP_Token_InterfaceTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected $class;
|
||||
protected $interfaces;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$ts = new PHP_Token_Stream(TEST_FILES_PATH . 'source4.php');
|
||||
$i = 0;
|
||||
foreach ($ts as $token) {
|
||||
if ($token instanceof PHP_Token_CLASS) {
|
||||
$this->class = $token;
|
||||
}
|
||||
elseif ($token instanceof PHP_Token_INTERFACE) {
|
||||
$this->interfaces[$i] = $token;
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_Token_INTERFACE::getName
|
||||
*/
|
||||
public function testGetName()
|
||||
{
|
||||
$this->assertEquals(
|
||||
'iTemplate', $this->interfaces[0]->getName()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_Token_INTERFACE::getParent
|
||||
*/
|
||||
public function testGetParentNotExists()
|
||||
{
|
||||
$this->assertFalse(
|
||||
$this->interfaces[0]->getParent()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_Token_INTERFACE::hasParent
|
||||
*/
|
||||
public function testHasParentNotExists()
|
||||
{
|
||||
$this->assertFalse(
|
||||
$this->interfaces[0]->hasParent()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_Token_INTERFACE::getParent
|
||||
*/
|
||||
public function testGetParentExists()
|
||||
{
|
||||
$this->assertEquals(
|
||||
'a', $this->interfaces[2]->getParent()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_Token_INTERFACE::hasParent
|
||||
*/
|
||||
public function testHasParentExists()
|
||||
{
|
||||
$this->assertTrue(
|
||||
$this->interfaces[2]->hasParent()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_Token_INTERFACE::getInterfaces
|
||||
*/
|
||||
public function testGetInterfacesExists()
|
||||
{
|
||||
$this->assertEquals(
|
||||
array('b'),
|
||||
$this->class->getInterfaces()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_Token_INTERFACE::hasInterfaces
|
||||
*/
|
||||
public function testHasInterfacesExists()
|
||||
{
|
||||
$this->assertTrue(
|
||||
$this->class->hasInterfaces()
|
||||
);
|
||||
}
|
||||
/**
|
||||
* @covers PHP_Token_INTERFACE::getPackage
|
||||
*/
|
||||
public function testGetPackageNamespace() {
|
||||
$tokenStream = new PHP_Token_Stream(TEST_FILES_PATH . 'classInNamespace.php');
|
||||
foreach($tokenStream as $token) {
|
||||
if($token instanceOf PHP_Token_INTERFACE) {
|
||||
$package = $token->getPackage();
|
||||
$this->assertSame('Foo\\Bar', $package['namespace']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function provideFilesWithClassesWithinMultipleNamespaces() {
|
||||
return array(
|
||||
array(TEST_FILES_PATH . 'multipleNamespacesWithOneClassUsingBraces.php'),
|
||||
array(TEST_FILES_PATH . 'multipleNamespacesWithOneClassUsingNonBraceSyntax.php'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideFilesWithClassesWithinMultipleNamespaces
|
||||
* @covers PHP_Token_INTERFACE::getPackage
|
||||
*/
|
||||
public function testGetPackageNamespaceForFileWithMultipleNamespaces($filepath) {
|
||||
$tokenStream = new PHP_Token_Stream($filepath);
|
||||
$firstClassFound = false;
|
||||
foreach($tokenStream as $token) {
|
||||
if($firstClassFound === false && $token instanceOf PHP_Token_INTERFACE) {
|
||||
$package = $token->getPackage();
|
||||
$this->assertSame('TestClassInBar', $token->getName());
|
||||
$this->assertSame('Foo\\Bar', $package['namespace']);
|
||||
$firstClassFound = true;
|
||||
continue;
|
||||
}
|
||||
// Secound class
|
||||
if($token instanceOf PHP_Token_INTERFACE) {
|
||||
$package = $token->getPackage();
|
||||
$this->assertSame('TestClassInBaz', $token->getName());
|
||||
$this->assertSame('Foo\\Baz', $package['namespace']);
|
||||
return;
|
||||
}
|
||||
}
|
||||
$this->fail("Seachring for 2 classes failed");
|
||||
}
|
||||
|
||||
public function testGetPackageNamespaceIsEmptyForInterfacesThatAreNotWithinNamespaces() {
|
||||
foreach($this->interfaces as $token) {
|
||||
$package = $token->getPackage();
|
||||
$this->assertSame("", $package['namespace']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_Token_INTERFACE::getPackage
|
||||
*/
|
||||
public function testGetPackageNamespaceWhenExtentingFromNamespaceClass() {
|
||||
$tokenStream = new PHP_Token_Stream(TEST_FILES_PATH . 'classExtendsNamespacedClass.php');
|
||||
$firstClassFound = false;
|
||||
foreach($tokenStream as $token) {
|
||||
if($firstClassFound === false && $token instanceOf PHP_Token_INTERFACE) {
|
||||
$package = $token->getPackage();
|
||||
$this->assertSame('Baz', $token->getName());
|
||||
$this->assertSame('Foo\\Bar', $package['namespace']);
|
||||
$firstClassFound = true;
|
||||
continue;
|
||||
}
|
||||
if($token instanceOf PHP_Token_INTERFACE) {
|
||||
$package = $token->getPackage();
|
||||
$this->assertSame('Extender', $token->getName());
|
||||
$this->assertSame('Other\\Space', $package['namespace']);
|
||||
return;
|
||||
}
|
||||
}
|
||||
$this->fail("Searching for 2 classes failed");
|
||||
}
|
||||
}
|
|
@ -1,80 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the PHP_TokenStream package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Tests for the PHP_Token_NAMESPACE class.
|
||||
*
|
||||
* @package PHP_TokenStream
|
||||
* @subpackage Tests
|
||||
* @author Sebastian Bergmann <sebastian@phpunit.de>
|
||||
* @copyright Sebastian Bergmann <sebastian@phpunit.de>
|
||||
* @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License
|
||||
* @version Release: @package_version@
|
||||
* @link http://github.com/sebastianbergmann/php-token-stream/
|
||||
* @since Class available since Release 1.0.0
|
||||
*/
|
||||
class PHP_Token_NamespaceTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @covers PHP_Token_NAMESPACE::getName
|
||||
*/
|
||||
public function testGetName()
|
||||
{
|
||||
$tokenStream = new PHP_Token_Stream(
|
||||
TEST_FILES_PATH . 'classInNamespace.php'
|
||||
);
|
||||
|
||||
foreach ($tokenStream as $token) {
|
||||
if ($token instanceof PHP_Token_NAMESPACE) {
|
||||
$this->assertSame('Foo\\Bar', $token->getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function testGetStartLineWithUnscopedNamespace()
|
||||
{
|
||||
$tokenStream = new PHP_Token_Stream(TEST_FILES_PATH . 'classInNamespace.php');
|
||||
foreach($tokenStream as $token) {
|
||||
if($token instanceOf PHP_Token_NAMESPACE) {
|
||||
$this->assertSame(2, $token->getLine());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function testGetEndLineWithUnscopedNamespace()
|
||||
{
|
||||
$tokenStream = new PHP_Token_Stream(TEST_FILES_PATH . 'classInNamespace.php');
|
||||
foreach($tokenStream as $token) {
|
||||
if($token instanceOf PHP_Token_NAMESPACE) {
|
||||
$this->assertSame(2, $token->getEndLine());
|
||||
}
|
||||
}
|
||||
}
|
||||
public function testGetStartLineWithScopedNamespace()
|
||||
{
|
||||
$tokenStream = new PHP_Token_Stream(TEST_FILES_PATH . 'classInScopedNamespace.php');
|
||||
foreach($tokenStream as $token) {
|
||||
if($token instanceOf PHP_Token_NAMESPACE) {
|
||||
$this->assertSame(2, $token->getLine());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function testGetEndLineWithScopedNamespace()
|
||||
{
|
||||
$tokenStream = new PHP_Token_Stream(TEST_FILES_PATH . 'classInScopedNamespace.php');
|
||||
foreach($tokenStream as $token) {
|
||||
if($token instanceOf PHP_Token_NAMESPACE) {
|
||||
$this->assertSame(8, $token->getEndLine());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the PHP_TokenStream package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Tests for the PHP_Token class.
|
||||
*
|
||||
* @package PHP_TokenStream
|
||||
* @subpackage Tests
|
||||
* @author Sebastian Bergmann <sebastian@phpunit.de>
|
||||
* @copyright Sebastian Bergmann <sebastian@phpunit.de>
|
||||
* @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License
|
||||
* @version Release: @package_version@
|
||||
* @link http://github.com/sebastianbergmann/php-token-stream/
|
||||
* @since Class available since Release 1.0.0
|
||||
*/
|
||||
class PHP_TokenTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @covers PHP_Token::__construct
|
||||
* @covers PHP_Token::__toString
|
||||
*/
|
||||
public function testToString()
|
||||
{
|
||||
$this->markTestIncomplete();
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_Token::__construct
|
||||
* @covers PHP_Token::getLine
|
||||
*/
|
||||
public function testGetLine()
|
||||
{
|
||||
$this->markTestIncomplete();
|
||||
}
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Foo\Bar;
|
||||
|
||||
class Baz {}
|
||||
|
||||
namespace Other\Space;
|
||||
|
||||
class Extender extends \Foo\Bar\Baz {}
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
<?php
|
||||
namespace Foo\Bar;
|
||||
|
||||
class TestClass
|
||||
{
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
<?php
|
||||
namespace Foo\BarScoped {
|
||||
|
||||
class TestClass {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
<?php
|
||||
interface foo {
|
||||
}
|
||||
|
||||
class class_with_method_that_declares_anonymous_class
|
||||
{
|
||||
public function method()
|
||||
{
|
||||
$o = new class { public function foo() {} };
|
||||
$o = new class{public function foo(){}};
|
||||
$o = new class extends stdClass {};
|
||||
$o = new class extends stdClass {};
|
||||
$o = new class implements foo {};
|
||||
}
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
<?php
|
||||
class Test {
|
||||
public function methodOne() {
|
||||
$foo = new class {
|
||||
public function method_in_anonymous_class() {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
return $foo->method_in_anonymous_class();
|
||||
}
|
||||
|
||||
public function methodTwo() {
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
<?php
|
||||
$function1 = function($foo, $bar) use ($var) {};
|
||||
$function2 = function(Foo $foo, $bar) use ($var) {};
|
||||
$function3 = function ($foo, $bar, $baz) {};
|
||||
$function4 = function (Foo $foo, $bar, $baz) {};
|
||||
$function5 = function () {};
|
||||
$function6 = function() {};
|
|
@ -1,3 +0,0 @@
|
|||
<?php
|
||||
class TestClass {
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
<?php
|
||||
class Foo
|
||||
{
|
||||
public function bar()
|
||||
{
|
||||
return Foo::CLASS;
|
||||
}
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
<?php
|
||||
namespace Foo\Bar;
|
||||
|
||||
class TestClassInBar
|
||||
{
|
||||
}
|
||||
|
||||
namespace Foo\Baz;
|
||||
|
||||
class TestClassInBaz
|
||||
{
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
<?php
|
||||
namespace Foo\Bar
|
||||
{
|
||||
class TestClassInBar
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
namespace Foo\Baz
|
||||
{
|
||||
class TestClassInBaz
|
||||
{
|
||||
}
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Some comment
|
||||
*/
|
||||
class Foo{function foo(){}
|
||||
|
||||
/**
|
||||
* @param Baz $baz
|
||||
*/
|
||||
public function bar(Baz $baz)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Foobar $foobar
|
||||
*/
|
||||
static public function foobar(Foobar $foobar)
|
||||
{
|
||||
}
|
||||
|
||||
public function barfoo(Barfoo $barfoo)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* This docblock does not belong to the baz function
|
||||
*/
|
||||
|
||||
public function baz()
|
||||
{
|
||||
}
|
||||
|
||||
public function blaz($x, $y)
|
||||
{
|
||||
}
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
<?php
|
||||
// short desc
|
||||
abstract class A {
|
||||
/* abst meth: */
|
||||
public static abstract function method();
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
<?php
|
||||
// This file is example#1
|
||||
// from http://www.php.net/manual/en/function.get-included-files.php
|
||||
|
||||
include 'test1.php';
|
||||
include_once 'test2.php';
|
||||
require 'test3.php';
|
||||
require_once 'test4.php';
|
||||
|
||||
$included_files = get_included_files();
|
||||
|
||||
foreach ($included_files as $filename) {
|
||||
echo "$filename\n";
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
<?php
|
||||
// Declare the interface 'iTemplate'
|
||||
interface iTemplate
|
||||
{
|
||||
public function setVariable($name, $var);
|
||||
public function
|
||||
getHtml($template);
|
||||
}
|
||||
|
||||
interface a
|
||||
{
|
||||
public function foo();
|
||||
}
|
||||
|
||||
interface b extends a
|
||||
{
|
||||
public function baz(Baz $baz);
|
||||
}
|
||||
|
||||
// short desc for class that implement a unique interface
|
||||
class c implements b
|
||||
{
|
||||
public function foo()
|
||||
{
|
||||
}
|
||||
|
||||
public function baz(Baz $baz)
|
||||
{
|
||||
}
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
<?php
|
||||
function foo($a, array $b, array $c = array()) {}
|
||||
interface i { public function m($a, array $b, array $c = array()); }
|
||||
abstract class a { abstract public function m($a, array $b, array $c = array()); }
|
||||
class c { public function m($a, array $b, array $c = array()) {} }
|
|
@ -1,7 +0,0 @@
|
|||
<?php
|
||||
require __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
define(
|
||||
'TEST_FILES_PATH',
|
||||
__DIR__ . DIRECTORY_SEPARATOR . '_fixture' . DIRECTORY_SEPARATOR
|
||||
);
|
|
@ -1,37 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
class Extensions_PhptTestCaseTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testParseIniSection()
|
||||
{
|
||||
$phptTestCase = new PhpTestCaseProxy(__FILE__);
|
||||
$settings = $phptTestCase->parseIniSection("foo=1\nbar = 2\rbaz = 3\r\nempty=\nignore");
|
||||
|
||||
$expected = array(
|
||||
'foo=1',
|
||||
'bar = 2',
|
||||
'baz = 3',
|
||||
'empty=',
|
||||
'ignore',
|
||||
);
|
||||
|
||||
$this->assertEquals($expected, $settings);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
class PhpTestCaseProxy extends PHPUnit_Extensions_PhptTestCase
|
||||
{
|
||||
public function parseIniSection($content)
|
||||
{
|
||||
return parent::parseIniSection($content);
|
||||
}
|
||||
}
|
|
@ -1,64 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @since Class available since Release 2.0.0
|
||||
* @covers PHPUnit_Extensions_RepeatedTest
|
||||
*/
|
||||
class Extensions_RepeatedTestTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected $suite;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->suite = new PHPUnit_Framework_TestSuite;
|
||||
|
||||
$this->suite->addTest(new Success);
|
||||
$this->suite->addTest(new Success);
|
||||
}
|
||||
|
||||
public function testRepeatedOnce()
|
||||
{
|
||||
$test = new PHPUnit_Extensions_RepeatedTest($this->suite, 1);
|
||||
$this->assertEquals(2, count($test));
|
||||
|
||||
$result = $test->run();
|
||||
$this->assertEquals(2, count($result));
|
||||
}
|
||||
|
||||
public function testRepeatedMoreThanOnce()
|
||||
{
|
||||
$test = new PHPUnit_Extensions_RepeatedTest($this->suite, 3);
|
||||
$this->assertEquals(6, count($test));
|
||||
|
||||
$result = $test->run();
|
||||
$this->assertEquals(6, count($result));
|
||||
}
|
||||
|
||||
public function testRepeatedZero()
|
||||
{
|
||||
$test = new PHPUnit_Extensions_RepeatedTest($this->suite, 0);
|
||||
$this->assertEquals(0, count($test));
|
||||
|
||||
$result = $test->run();
|
||||
$this->assertEquals(0, count($result));
|
||||
}
|
||||
|
||||
public function testRepeatedNegative()
|
||||
{
|
||||
try {
|
||||
$test = new PHPUnit_Extensions_RepeatedTest($this->suite, -1);
|
||||
} catch (Exception $e) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->fail('Should throw an Exception');
|
||||
}
|
||||
}
|
5
vendor/phpunit/phpunit/tests/Fail/fail.phpt
vendored
5
vendor/phpunit/phpunit/tests/Fail/fail.phpt
vendored
|
@ -1,5 +0,0 @@
|
|||
--TEST--
|
||||
// This test intentionally fails and it is checked by Travis.
|
||||
--FILE--
|
||||
--EXPECTF--
|
||||
unexpected
|
4130
vendor/phpunit/phpunit/tests/Framework/AssertTest.php
vendored
4130
vendor/phpunit/phpunit/tests/Framework/AssertTest.php
vendored
File diff suppressed because it is too large
Load diff
|
@ -1,34 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @since Class available since Release 4.0.0
|
||||
*/
|
||||
class Framework_BaseTestListenerTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @var PHPUnit_Framework_TestResult
|
||||
*/
|
||||
private $result;
|
||||
|
||||
/**
|
||||
* @covers PHPUnit_Framework_TestResult
|
||||
*/
|
||||
public function testEndEventsAreCounted()
|
||||
{
|
||||
$this->result = new PHPUnit_Framework_TestResult;
|
||||
$listener = new BaseTestListenerSample();
|
||||
$this->result->addListener($listener);
|
||||
$test = new Success;
|
||||
$test->run($this->result);
|
||||
|
||||
$this->assertEquals(1, $listener->endCount);
|
||||
}
|
||||
}
|
|
@ -1,63 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @since Class available since Release 3.7.30
|
||||
* @covers PHPUnit_Framework_Constraint_Count
|
||||
*/
|
||||
class CountTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testCount()
|
||||
{
|
||||
$countConstraint = new PHPUnit_Framework_Constraint_Count(3);
|
||||
$this->assertTrue($countConstraint->evaluate(array(1, 2, 3), '', true));
|
||||
|
||||
$countConstraint = new PHPUnit_Framework_Constraint_Count(0);
|
||||
$this->assertTrue($countConstraint->evaluate(array(), '', true));
|
||||
|
||||
$countConstraint = new PHPUnit_Framework_Constraint_Count(2);
|
||||
$it = new TestIterator(array(1, 2));
|
||||
$this->assertTrue($countConstraint->evaluate($it, '', true));
|
||||
}
|
||||
|
||||
public function testCountDoesNotChangeIteratorKey()
|
||||
{
|
||||
$countConstraint = new PHPUnit_Framework_Constraint_Count(2);
|
||||
|
||||
// test with 1st implementation of Iterator
|
||||
$it = new TestIterator(array(1, 2));
|
||||
|
||||
$countConstraint->evaluate($it, '', true);
|
||||
$this->assertEquals(1, $it->current());
|
||||
|
||||
$it->next();
|
||||
$countConstraint->evaluate($it, '', true);
|
||||
$this->assertEquals(2, $it->current());
|
||||
|
||||
$it->next();
|
||||
$countConstraint->evaluate($it, '', true);
|
||||
$this->assertFalse($it->valid());
|
||||
|
||||
// test with 2nd implementation of Iterator
|
||||
$it = new TestIterator2(array(1, 2));
|
||||
|
||||
$countConstraint = new PHPUnit_Framework_Constraint_Count(2);
|
||||
$countConstraint->evaluate($it, '', true);
|
||||
$this->assertEquals(1, $it->current());
|
||||
|
||||
$it->next();
|
||||
$countConstraint->evaluate($it, '', true);
|
||||
$this->assertEquals(2, $it->current());
|
||||
|
||||
$it->next();
|
||||
$countConstraint->evaluate($it, '', true);
|
||||
$this->assertFalse($it->valid());
|
||||
}
|
||||
}
|
|
@ -1,56 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @since Class available since Release 4.3.0
|
||||
* @covers PHPUnit_Framework_Constraint_ExceptionMessageRegExp
|
||||
*/
|
||||
class ExceptionMessageRegExpTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @expectedException \Exception
|
||||
* @expectedExceptionMessageRegExp /^A polymorphic \w+ message/
|
||||
*/
|
||||
public function testRegexMessage()
|
||||
{
|
||||
throw new Exception('A polymorphic exception message');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Exception
|
||||
* @expectedExceptionMessageRegExp /^a poly[a-z]+ [a-zA-Z0-9_]+ me(s){2}age$/i
|
||||
*/
|
||||
public function testRegexMessageExtreme()
|
||||
{
|
||||
throw new Exception('A polymorphic exception message');
|
||||
}
|
||||
|
||||
/**
|
||||
* @runInSeparateProcess
|
||||
* @requires extension xdebug
|
||||
* @expectedException \Exception
|
||||
* @expectedExceptionMessageRegExp #Screaming preg_match#
|
||||
*/
|
||||
public function testMessageXdebugScreamCompatibility()
|
||||
{
|
||||
ini_set('xdebug.scream', '1');
|
||||
throw new Exception('Screaming preg_match');
|
||||
}
|
||||
|
||||
/**
|
||||
* @coversNothing
|
||||
* @expectedException \Exception variadic
|
||||
* @expectedExceptionMessageRegExp /^A variadic \w+ message/
|
||||
*/
|
||||
public function testSimultaneousLiteralAndRegExpExceptionMessage()
|
||||
{
|
||||
throw new Exception('A variadic exception message');
|
||||
}
|
||||
}
|
|
@ -1,52 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @since Class available since Release 4.0.20
|
||||
* @covers PHPUnit_Framework_Constraint_ExceptionMessage
|
||||
*/
|
||||
class ExceptionMessageTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @expectedException \Exception
|
||||
* @expectedExceptionMessage A literal exception message
|
||||
*/
|
||||
public function testLiteralMessage()
|
||||
{
|
||||
throw new Exception('A literal exception message');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Exception
|
||||
* @expectedExceptionMessage A partial
|
||||
*/
|
||||
public function testPatialMessageBegin()
|
||||
{
|
||||
throw new Exception('A partial exception message');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Exception
|
||||
* @expectedExceptionMessage partial exception
|
||||
*/
|
||||
public function testPatialMessageMiddle()
|
||||
{
|
||||
throw new Exception('A partial exception message');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Exception
|
||||
* @expectedExceptionMessage exception message
|
||||
*/
|
||||
public function testPatialMessageEnd()
|
||||
{
|
||||
throw new Exception('A partial exception message');
|
||||
}
|
||||
}
|
|
@ -1,83 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @since File available since Release 3.7.0
|
||||
*/
|
||||
class Framework_Constraint_JsonMatches_ErrorMessageProviderTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider translateTypeToPrefixDataprovider
|
||||
* @covers PHPUnit_Framework_Constraint_JsonMatches_ErrorMessageProvider::translateTypeToPrefix
|
||||
*/
|
||||
public function testTranslateTypeToPrefix($expected, $type)
|
||||
{
|
||||
$this->assertEquals(
|
||||
$expected,
|
||||
PHPUnit_Framework_Constraint_JsonMatches_ErrorMessageProvider::translateTypeToPrefix($type)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider determineJsonErrorDataprovider
|
||||
* @covers PHPUnit_Framework_Constraint_JsonMatches_ErrorMessageProvider::determineJsonError
|
||||
*/
|
||||
public function testDetermineJsonError($expected, $error, $prefix)
|
||||
{
|
||||
$this->assertEquals(
|
||||
$expected,
|
||||
PHPUnit_Framework_Constraint_JsonMatches_ErrorMessageProvider::determineJsonError(
|
||||
$error,
|
||||
$prefix
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public static function determineJsonErrorDataprovider()
|
||||
{
|
||||
return array(
|
||||
'JSON_ERROR_NONE' => array(
|
||||
null, 'json_error_none', ''
|
||||
),
|
||||
'JSON_ERROR_DEPTH' => array(
|
||||
'Maximum stack depth exceeded', JSON_ERROR_DEPTH, ''
|
||||
),
|
||||
'prefixed JSON_ERROR_DEPTH' => array(
|
||||
'TUX: Maximum stack depth exceeded', JSON_ERROR_DEPTH, 'TUX: '
|
||||
),
|
||||
'JSON_ERROR_STATE_MISMatch' => array(
|
||||
'Underflow or the modes mismatch', JSON_ERROR_STATE_MISMATCH, ''
|
||||
),
|
||||
'JSON_ERROR_CTRL_CHAR' => array(
|
||||
'Unexpected control character found', JSON_ERROR_CTRL_CHAR, ''
|
||||
),
|
||||
'JSON_ERROR_SYNTAX' => array(
|
||||
'Syntax error, malformed JSON', JSON_ERROR_SYNTAX, ''
|
||||
),
|
||||
'JSON_ERROR_UTF8`' => array(
|
||||
'Malformed UTF-8 characters, possibly incorrectly encoded',
|
||||
JSON_ERROR_UTF8,
|
||||
''
|
||||
),
|
||||
'Invalid error indicator' => array(
|
||||
'Unknown error', 55, ''
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
public static function translateTypeToPrefixDataprovider()
|
||||
{
|
||||
return array(
|
||||
'expected' => array('Expected value JSON decode error - ', 'expected'),
|
||||
'actual' => array('Actual value JSON decode error - ', 'actual'),
|
||||
'default' => array('', ''),
|
||||
);
|
||||
}
|
||||
}
|
|
@ -1,48 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @since File available since Release 3.7.0
|
||||
*/
|
||||
class Framework_Constraint_JsonMatchesTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider evaluateDataprovider
|
||||
* @covers PHPUnit_Framework_Constraint_JsonMatches::evaluate
|
||||
* @covers PHPUnit_Framework_Constraint_JsonMatches::matches
|
||||
* @covers PHPUnit_Framework_Constraint_JsonMatches::__construct
|
||||
*/
|
||||
public function testEvaluate($expected, $jsonOther, $jsonValue)
|
||||
{
|
||||
$constraint = new PHPUnit_Framework_Constraint_JsonMatches($jsonValue);
|
||||
$this->assertEquals($expected, $constraint->evaluate($jsonOther, '', true));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHPUnit_Framework_Constraint_JsonMatches::toString
|
||||
*/
|
||||
public function testToString()
|
||||
{
|
||||
$jsonValue = json_encode(array('Mascott' => 'Tux'));
|
||||
$constraint = new PHPUnit_Framework_Constraint_JsonMatches($jsonValue);
|
||||
|
||||
$this->assertEquals('matches JSON string "' . $jsonValue . '"', $constraint->toString());
|
||||
}
|
||||
|
||||
public static function evaluateDataprovider()
|
||||
{
|
||||
return array(
|
||||
'valid JSON' => array(true, json_encode(array('Mascott' => 'Tux')), json_encode(array('Mascott' => 'Tux'))),
|
||||
'error syntax' => array(false, '{"Mascott"::}', json_encode(array('Mascott' => 'Tux'))),
|
||||
'error UTF-8' => array(false, json_encode('\xB1\x31'), json_encode(array('Mascott' => 'Tux'))),
|
||||
'invalid JSON in class instantiation' => array(false, json_encode(array('Mascott' => 'Tux')), '{"Mascott"::}'),
|
||||
);
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load diff
242
vendor/phpunit/phpunit/tests/Framework/SuiteTest.php
vendored
242
vendor/phpunit/phpunit/tests/Framework/SuiteTest.php
vendored
|
@ -1,242 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
require_once dirname(__DIR__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'BeforeAndAfterTest.php';
|
||||
require_once dirname(__DIR__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'BeforeClassAndAfterClassTest.php';
|
||||
require_once dirname(__DIR__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'TestWithTest.php';
|
||||
require_once dirname(__DIR__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'DataProviderSkippedTest.php';
|
||||
require_once dirname(__DIR__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'DataProviderIncompleteTest.php';
|
||||
require_once dirname(__DIR__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'InheritedTestCase.php';
|
||||
require_once dirname(__DIR__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'NoTestCaseClass.php';
|
||||
require_once dirname(__DIR__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'NoTestCases.php';
|
||||
require_once dirname(__DIR__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'NotPublicTestCase.php';
|
||||
require_once dirname(__DIR__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'NotVoidTestCase.php';
|
||||
require_once dirname(__DIR__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'OverrideTestCase.php';
|
||||
require_once dirname(__DIR__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'RequirementsClassBeforeClassHookTest.php';
|
||||
|
||||
/**
|
||||
* @since Class available since Release 2.0.0
|
||||
* @covers PHPUnit_Framework_TestSuite
|
||||
*/
|
||||
class Framework_SuiteTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected $result;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->result = new PHPUnit_Framework_TestResult;
|
||||
}
|
||||
|
||||
public static function suite()
|
||||
{
|
||||
$suite = new PHPUnit_Framework_TestSuite;
|
||||
|
||||
$suite->addTest(new self('testAddTestSuite'));
|
||||
$suite->addTest(new self('testInheritedTests'));
|
||||
$suite->addTest(new self('testNoTestCases'));
|
||||
$suite->addTest(new self('testNoTestCaseClass'));
|
||||
$suite->addTest(new self('testNotExistingTestCase'));
|
||||
$suite->addTest(new self('testNotPublicTestCase'));
|
||||
$suite->addTest(new self('testNotVoidTestCase'));
|
||||
$suite->addTest(new self('testOneTestCase'));
|
||||
$suite->addTest(new self('testShadowedTests'));
|
||||
$suite->addTest(new self('testBeforeClassAndAfterClassAnnotations'));
|
||||
$suite->addTest(new self('testBeforeAnnotation'));
|
||||
$suite->addTest(new self('testTestWithAnnotation'));
|
||||
$suite->addTest(new self('testSkippedTestDataProvider'));
|
||||
$suite->addTest(new self('testIncompleteTestDataProvider'));
|
||||
$suite->addTest(new self('testRequirementsBeforeClassHook'));
|
||||
$suite->addTest(new self('testDontSkipInheritedClass'));
|
||||
|
||||
return $suite;
|
||||
}
|
||||
|
||||
public function testAddTestSuite()
|
||||
{
|
||||
$suite = new PHPUnit_Framework_TestSuite(
|
||||
'OneTestCase'
|
||||
);
|
||||
|
||||
$suite->run($this->result);
|
||||
|
||||
$this->assertEquals(1, count($this->result));
|
||||
}
|
||||
|
||||
public function testInheritedTests()
|
||||
{
|
||||
$suite = new PHPUnit_Framework_TestSuite(
|
||||
'InheritedTestCase'
|
||||
);
|
||||
|
||||
$suite->run($this->result);
|
||||
|
||||
$this->assertTrue($this->result->wasSuccessful());
|
||||
$this->assertEquals(2, count($this->result));
|
||||
}
|
||||
|
||||
public function testNoTestCases()
|
||||
{
|
||||
$suite = new PHPUnit_Framework_TestSuite(
|
||||
'NoTestCases'
|
||||
);
|
||||
|
||||
$suite->run($this->result);
|
||||
|
||||
$this->assertTrue(!$this->result->wasSuccessful());
|
||||
$this->assertEquals(1, $this->result->failureCount());
|
||||
$this->assertEquals(1, count($this->result));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException PHPUnit_Framework_Exception
|
||||
*/
|
||||
public function testNoTestCaseClass()
|
||||
{
|
||||
$suite = new PHPUnit_Framework_TestSuite('NoTestCaseClass');
|
||||
}
|
||||
|
||||
public function testNotExistingTestCase()
|
||||
{
|
||||
$suite = new self('notExistingMethod');
|
||||
|
||||
$suite->run($this->result);
|
||||
|
||||
$this->assertEquals(0, $this->result->errorCount());
|
||||
$this->assertEquals(1, $this->result->failureCount());
|
||||
$this->assertEquals(1, count($this->result));
|
||||
}
|
||||
|
||||
public function testNotPublicTestCase()
|
||||
{
|
||||
$suite = new PHPUnit_Framework_TestSuite(
|
||||
'NotPublicTestCase'
|
||||
);
|
||||
|
||||
$this->assertEquals(2, count($suite));
|
||||
}
|
||||
|
||||
public function testNotVoidTestCase()
|
||||
{
|
||||
$suite = new PHPUnit_Framework_TestSuite(
|
||||
'NotVoidTestCase'
|
||||
);
|
||||
|
||||
$this->assertEquals(1, count($suite));
|
||||
}
|
||||
|
||||
public function testOneTestCase()
|
||||
{
|
||||
$suite = new PHPUnit_Framework_TestSuite(
|
||||
'OneTestCase'
|
||||
);
|
||||
|
||||
$suite->run($this->result);
|
||||
|
||||
$this->assertEquals(0, $this->result->errorCount());
|
||||
$this->assertEquals(0, $this->result->failureCount());
|
||||
$this->assertEquals(1, count($this->result));
|
||||
$this->assertTrue($this->result->wasSuccessful());
|
||||
}
|
||||
|
||||
public function testShadowedTests()
|
||||
{
|
||||
$suite = new PHPUnit_Framework_TestSuite(
|
||||
'OverrideTestCase'
|
||||
);
|
||||
|
||||
$suite->run($this->result);
|
||||
|
||||
$this->assertEquals(1, count($this->result));
|
||||
}
|
||||
|
||||
public function testBeforeClassAndAfterClassAnnotations()
|
||||
{
|
||||
$suite = new PHPUnit_Framework_TestSuite(
|
||||
'BeforeClassAndAfterClassTest'
|
||||
);
|
||||
|
||||
BeforeClassAndAfterClassTest::resetProperties();
|
||||
$suite->run($this->result);
|
||||
|
||||
$this->assertEquals(1, BeforeClassAndAfterClassTest::$beforeClassWasRun, '@beforeClass method was not run once for the whole suite.');
|
||||
$this->assertEquals(1, BeforeClassAndAfterClassTest::$afterClassWasRun, '@afterClass method was not run once for the whole suite.');
|
||||
}
|
||||
|
||||
public function testBeforeAnnotation()
|
||||
{
|
||||
$test = new PHPUnit_Framework_TestSuite(
|
||||
'BeforeAndAfterTest'
|
||||
);
|
||||
|
||||
BeforeAndAfterTest::resetProperties();
|
||||
$result = $test->run();
|
||||
|
||||
$this->assertEquals(2, BeforeAndAfterTest::$beforeWasRun);
|
||||
$this->assertEquals(2, BeforeAndAfterTest::$afterWasRun);
|
||||
}
|
||||
|
||||
public function testTestWithAnnotation()
|
||||
{
|
||||
$test = new PHPUnit_Framework_TestSuite(
|
||||
'TestWithTest'
|
||||
);
|
||||
|
||||
BeforeAndAfterTest::resetProperties();
|
||||
$result = $test->run();
|
||||
|
||||
$this->assertEquals(4, count($result->passed()));
|
||||
}
|
||||
|
||||
public function testSkippedTestDataProvider()
|
||||
{
|
||||
$suite = new PHPUnit_Framework_TestSuite('DataProviderSkippedTest');
|
||||
|
||||
$suite->run($this->result);
|
||||
|
||||
$this->assertEquals(3, $this->result->count());
|
||||
$this->assertEquals(1, $this->result->skippedCount());
|
||||
}
|
||||
|
||||
public function testIncompleteTestDataProvider()
|
||||
{
|
||||
$suite = new PHPUnit_Framework_TestSuite('DataProviderIncompleteTest');
|
||||
|
||||
$suite->run($this->result);
|
||||
|
||||
$this->assertEquals(3, $this->result->count());
|
||||
$this->assertEquals(1, $this->result->notImplementedCount());
|
||||
}
|
||||
|
||||
public function testRequirementsBeforeClassHook()
|
||||
{
|
||||
$suite = new PHPUnit_Framework_TestSuite(
|
||||
'RequirementsClassBeforeClassHookTest'
|
||||
);
|
||||
|
||||
$suite->run($this->result);
|
||||
|
||||
$this->assertEquals(0, $this->result->errorCount());
|
||||
$this->assertEquals(1, $this->result->skippedCount());
|
||||
}
|
||||
|
||||
public function testDontSkipInheritedClass()
|
||||
{
|
||||
$suite = new PHPUnit_Framework_TestSuite(
|
||||
'DontSkipInheritedClass'
|
||||
);
|
||||
|
||||
$dir = dirname(__DIR__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'Inheritance' . DIRECTORY_SEPARATOR;
|
||||
|
||||
$suite->addTestFile($dir . 'InheritanceA.php');
|
||||
$suite->addTestFile($dir . 'InheritanceB.php');
|
||||
$result = $suite->run();
|
||||
$this->assertEquals(2, count($result));
|
||||
}
|
||||
}
|
|
@ -1,550 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
require_once dirname(__DIR__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'NoArgTestCaseTest.php';
|
||||
require_once dirname(__DIR__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'Singleton.php';
|
||||
|
||||
$GLOBALS['a'] = 'a';
|
||||
$_ENV['b'] = 'b';
|
||||
$_POST['c'] = 'c';
|
||||
$_GET['d'] = 'd';
|
||||
$_COOKIE['e'] = 'e';
|
||||
$_SERVER['f'] = 'f';
|
||||
$_FILES['g'] = 'g';
|
||||
$_REQUEST['h'] = 'h';
|
||||
$GLOBALS['i'] = 'i';
|
||||
|
||||
/**
|
||||
* @since Class available since Release 2.0.0
|
||||
* @covers PHPUnit_Framework_TestCase
|
||||
*/
|
||||
class Framework_TestCaseTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected $backupGlobalsBlacklist = array('i', 'singleton');
|
||||
|
||||
/**
|
||||
* Used be testStaticAttributesBackupPre
|
||||
*/
|
||||
protected static $_testStatic = 0;
|
||||
|
||||
public function testCaseToString()
|
||||
{
|
||||
$this->assertEquals(
|
||||
'Framework_TestCaseTest::testCaseToString',
|
||||
$this->toString()
|
||||
);
|
||||
}
|
||||
|
||||
public function testSuccess()
|
||||
{
|
||||
$test = new Success;
|
||||
$result = $test->run();
|
||||
|
||||
$this->assertEquals(PHPUnit_Runner_BaseTestRunner::STATUS_PASSED, $test->getStatus());
|
||||
$this->assertEquals(0, $result->errorCount());
|
||||
$this->assertEquals(0, $result->failureCount());
|
||||
$this->assertEquals(0, $result->skippedCount());
|
||||
$this->assertEquals(1, count($result));
|
||||
}
|
||||
|
||||
public function testFailure()
|
||||
{
|
||||
$test = new Failure;
|
||||
$result = $test->run();
|
||||
|
||||
$this->assertEquals(PHPUnit_Runner_BaseTestRunner::STATUS_FAILURE, $test->getStatus());
|
||||
$this->assertEquals(0, $result->errorCount());
|
||||
$this->assertEquals(1, $result->failureCount());
|
||||
$this->assertEquals(0, $result->skippedCount());
|
||||
$this->assertEquals(1, count($result));
|
||||
}
|
||||
|
||||
public function testError()
|
||||
{
|
||||
$test = new TestError;
|
||||
$result = $test->run();
|
||||
|
||||
$this->assertEquals(PHPUnit_Runner_BaseTestRunner::STATUS_ERROR, $test->getStatus());
|
||||
$this->assertEquals(1, $result->errorCount());
|
||||
$this->assertEquals(0, $result->failureCount());
|
||||
$this->assertEquals(0, $result->skippedCount());
|
||||
$this->assertEquals(1, count($result));
|
||||
}
|
||||
|
||||
public function testSkipped()
|
||||
{
|
||||
$test = new TestSkipped();
|
||||
$result = $test->run();
|
||||
|
||||
$this->assertEquals(PHPUnit_Runner_BaseTestRunner::STATUS_SKIPPED, $test->getStatus());
|
||||
$this->assertEquals('Skipped test', $test->getStatusMessage());
|
||||
$this->assertEquals(0, $result->errorCount());
|
||||
$this->assertEquals(0, $result->failureCount());
|
||||
$this->assertEquals(1, $result->skippedCount());
|
||||
$this->assertEquals(1, count($result));
|
||||
}
|
||||
|
||||
public function testIncomplete()
|
||||
{
|
||||
$test = new TestIncomplete();
|
||||
$result = $test->run();
|
||||
|
||||
$this->assertEquals(PHPUnit_Runner_BaseTestRunner::STATUS_INCOMPLETE, $test->getStatus());
|
||||
$this->assertEquals('Incomplete test', $test->getStatusMessage());
|
||||
$this->assertEquals(0, $result->errorCount());
|
||||
$this->assertEquals(0, $result->failureCount());
|
||||
$this->assertEquals(0, $result->skippedCount());
|
||||
$this->assertEquals(1, count($result));
|
||||
}
|
||||
|
||||
public function testExceptionInSetUp()
|
||||
{
|
||||
$test = new ExceptionInSetUpTest('testSomething');
|
||||
$result = $test->run();
|
||||
|
||||
$this->assertTrue($test->setUp);
|
||||
$this->assertFalse($test->assertPreConditions);
|
||||
$this->assertFalse($test->testSomething);
|
||||
$this->assertFalse($test->assertPostConditions);
|
||||
$this->assertTrue($test->tearDown);
|
||||
}
|
||||
|
||||
public function testExceptionInAssertPreConditions()
|
||||
{
|
||||
$test = new ExceptionInAssertPreConditionsTest('testSomething');
|
||||
$result = $test->run();
|
||||
|
||||
$this->assertTrue($test->setUp);
|
||||
$this->assertTrue($test->assertPreConditions);
|
||||
$this->assertFalse($test->testSomething);
|
||||
$this->assertFalse($test->assertPostConditions);
|
||||
$this->assertTrue($test->tearDown);
|
||||
}
|
||||
|
||||
public function testExceptionInTest()
|
||||
{
|
||||
$test = new ExceptionInTest('testSomething');
|
||||
$result = $test->run();
|
||||
|
||||
$this->assertTrue($test->setUp);
|
||||
$this->assertTrue($test->assertPreConditions);
|
||||
$this->assertTrue($test->testSomething);
|
||||
$this->assertFalse($test->assertPostConditions);
|
||||
$this->assertTrue($test->tearDown);
|
||||
}
|
||||
|
||||
public function testExceptionInAssertPostConditions()
|
||||
{
|
||||
$test = new ExceptionInAssertPostConditionsTest('testSomething');
|
||||
$result = $test->run();
|
||||
|
||||
$this->assertTrue($test->setUp);
|
||||
$this->assertTrue($test->assertPreConditions);
|
||||
$this->assertTrue($test->testSomething);
|
||||
$this->assertTrue($test->assertPostConditions);
|
||||
$this->assertTrue($test->tearDown);
|
||||
}
|
||||
|
||||
public function testExceptionInTearDown()
|
||||
{
|
||||
$test = new ExceptionInTearDownTest('testSomething');
|
||||
$result = $test->run();
|
||||
|
||||
$this->assertTrue($test->setUp);
|
||||
$this->assertTrue($test->assertPreConditions);
|
||||
$this->assertTrue($test->testSomething);
|
||||
$this->assertTrue($test->assertPostConditions);
|
||||
$this->assertTrue($test->tearDown);
|
||||
}
|
||||
|
||||
public function testNoArgTestCasePasses()
|
||||
{
|
||||
$result = new PHPUnit_Framework_TestResult;
|
||||
$t = new PHPUnit_Framework_TestSuite('NoArgTestCaseTest');
|
||||
|
||||
$t->run($result);
|
||||
|
||||
$this->assertEquals(1, count($result));
|
||||
$this->assertEquals(0, $result->failureCount());
|
||||
$this->assertEquals(0, $result->errorCount());
|
||||
}
|
||||
|
||||
public function testWasRun()
|
||||
{
|
||||
$test = new WasRun;
|
||||
$test->run();
|
||||
|
||||
$this->assertTrue($test->wasRun);
|
||||
}
|
||||
|
||||
public function testException()
|
||||
{
|
||||
$test = new ThrowExceptionTestCase('test');
|
||||
$test->setExpectedException('RuntimeException');
|
||||
|
||||
$result = $test->run();
|
||||
|
||||
$this->assertEquals(1, count($result));
|
||||
$this->assertTrue($result->wasSuccessful());
|
||||
}
|
||||
|
||||
public function testExceptionWithMessage()
|
||||
{
|
||||
$test = new ThrowExceptionTestCase('test');
|
||||
$test->setExpectedException('RuntimeException', 'A runtime error occurred');
|
||||
|
||||
$result = $test->run();
|
||||
|
||||
$this->assertEquals(1, count($result));
|
||||
$this->assertTrue($result->wasSuccessful());
|
||||
}
|
||||
|
||||
public function testExceptionWithWrongMessage()
|
||||
{
|
||||
$test = new ThrowExceptionTestCase('test');
|
||||
$test->setExpectedException('RuntimeException', 'A logic error occurred');
|
||||
|
||||
$result = $test->run();
|
||||
|
||||
$this->assertEquals(1, $result->failureCount());
|
||||
$this->assertEquals(1, count($result));
|
||||
$this->assertEquals(
|
||||
"Failed asserting that exception message 'A runtime error occurred' contains 'A logic error occurred'.",
|
||||
$test->getStatusMessage()
|
||||
);
|
||||
}
|
||||
|
||||
public function testExceptionWithRegexpMessage()
|
||||
{
|
||||
$test = new ThrowExceptionTestCase('test');
|
||||
$test->setExpectedExceptionRegExp('RuntimeException', '/runtime .*? occurred/');
|
||||
|
||||
$result = $test->run();
|
||||
|
||||
$this->assertEquals(1, count($result));
|
||||
$this->assertTrue($result->wasSuccessful());
|
||||
}
|
||||
|
||||
public function testExceptionWithWrongRegexpMessage()
|
||||
{
|
||||
$test = new ThrowExceptionTestCase('test');
|
||||
$test->setExpectedExceptionRegExp('RuntimeException', '/logic .*? occurred/');
|
||||
|
||||
$result = $test->run();
|
||||
|
||||
$this->assertEquals(1, $result->failureCount());
|
||||
$this->assertEquals(1, count($result));
|
||||
$this->assertEquals(
|
||||
"Failed asserting that exception message 'A runtime error occurred' matches '/logic .*? occurred/'.",
|
||||
$test->getStatusMessage()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHPUnit_Framework_Constraint_ExceptionMessageRegExp
|
||||
*/
|
||||
public function testExceptionWithInvalidRegexpMessage()
|
||||
{
|
||||
$test = new ThrowExceptionTestCase('test');
|
||||
$test->setExpectedExceptionRegExp('RuntimeException', '#runtime .*? occurred/'); // wrong delimiter
|
||||
|
||||
$result = $test->run();
|
||||
|
||||
$this->assertEquals(
|
||||
"Invalid expected exception message regex given: '#runtime .*? occurred/'",
|
||||
$test->getStatusMessage()
|
||||
);
|
||||
}
|
||||
|
||||
public function testNoException()
|
||||
{
|
||||
$test = new ThrowNoExceptionTestCase('test');
|
||||
$test->setExpectedException('RuntimeException');
|
||||
|
||||
$result = $test->run();
|
||||
|
||||
$this->assertEquals(1, $result->failureCount());
|
||||
$this->assertEquals(1, count($result));
|
||||
}
|
||||
|
||||
public function testWrongException()
|
||||
{
|
||||
$test = new ThrowExceptionTestCase('test');
|
||||
$test->setExpectedException('InvalidArgumentException');
|
||||
|
||||
$result = $test->run();
|
||||
|
||||
$this->assertEquals(1, $result->failureCount());
|
||||
$this->assertEquals(1, count($result));
|
||||
}
|
||||
|
||||
/**
|
||||
* @backupGlobals enabled
|
||||
*/
|
||||
public function testGlobalsBackupPre()
|
||||
{
|
||||
global $a;
|
||||
global $i;
|
||||
|
||||
$this->assertEquals('a', $a);
|
||||
$this->assertEquals('a', $GLOBALS['a']);
|
||||
$this->assertEquals('b', $_ENV['b']);
|
||||
$this->assertEquals('c', $_POST['c']);
|
||||
$this->assertEquals('d', $_GET['d']);
|
||||
$this->assertEquals('e', $_COOKIE['e']);
|
||||
$this->assertEquals('f', $_SERVER['f']);
|
||||
$this->assertEquals('g', $_FILES['g']);
|
||||
$this->assertEquals('h', $_REQUEST['h']);
|
||||
$this->assertEquals('i', $i);
|
||||
$this->assertEquals('i', $GLOBALS['i']);
|
||||
|
||||
$GLOBALS['a'] = 'aa';
|
||||
$GLOBALS['foo'] = 'bar';
|
||||
$_ENV['b'] = 'bb';
|
||||
$_POST['c'] = 'cc';
|
||||
$_GET['d'] = 'dd';
|
||||
$_COOKIE['e'] = 'ee';
|
||||
$_SERVER['f'] = 'ff';
|
||||
$_FILES['g'] = 'gg';
|
||||
$_REQUEST['h'] = 'hh';
|
||||
$GLOBALS['i'] = 'ii';
|
||||
|
||||
$this->assertEquals('aa', $a);
|
||||
$this->assertEquals('aa', $GLOBALS['a']);
|
||||
$this->assertEquals('bar', $GLOBALS['foo']);
|
||||
$this->assertEquals('bb', $_ENV['b']);
|
||||
$this->assertEquals('cc', $_POST['c']);
|
||||
$this->assertEquals('dd', $_GET['d']);
|
||||
$this->assertEquals('ee', $_COOKIE['e']);
|
||||
$this->assertEquals('ff', $_SERVER['f']);
|
||||
$this->assertEquals('gg', $_FILES['g']);
|
||||
$this->assertEquals('hh', $_REQUEST['h']);
|
||||
$this->assertEquals('ii', $i);
|
||||
$this->assertEquals('ii', $GLOBALS['i']);
|
||||
}
|
||||
|
||||
public function testGlobalsBackupPost()
|
||||
{
|
||||
global $a;
|
||||
global $i;
|
||||
|
||||
$this->assertEquals('a', $a);
|
||||
$this->assertEquals('a', $GLOBALS['a']);
|
||||
$this->assertEquals('b', $_ENV['b']);
|
||||
$this->assertEquals('c', $_POST['c']);
|
||||
$this->assertEquals('d', $_GET['d']);
|
||||
$this->assertEquals('e', $_COOKIE['e']);
|
||||
$this->assertEquals('f', $_SERVER['f']);
|
||||
$this->assertEquals('g', $_FILES['g']);
|
||||
$this->assertEquals('h', $_REQUEST['h']);
|
||||
$this->assertEquals('ii', $i);
|
||||
$this->assertEquals('ii', $GLOBALS['i']);
|
||||
|
||||
$this->assertArrayNotHasKey('foo', $GLOBALS);
|
||||
}
|
||||
|
||||
/**
|
||||
* @backupGlobals enabled
|
||||
* @backupStaticAttributes enabled
|
||||
*/
|
||||
public function testStaticAttributesBackupPre()
|
||||
{
|
||||
$GLOBALS['singleton'] = Singleton::getInstance();
|
||||
self::$_testStatic = 123;
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testStaticAttributesBackupPre
|
||||
*/
|
||||
public function testStaticAttributesBackupPost()
|
||||
{
|
||||
$this->assertNotSame($GLOBALS['singleton'], Singleton::getInstance());
|
||||
$this->assertSame(0, self::$_testStatic);
|
||||
}
|
||||
|
||||
public function testIsInIsolationReturnsFalse()
|
||||
{
|
||||
$test = new IsolationTest('testIsInIsolationReturnsFalse');
|
||||
$result = $test->run();
|
||||
|
||||
$this->assertEquals(1, count($result));
|
||||
$this->assertTrue($result->wasSuccessful());
|
||||
}
|
||||
|
||||
public function testIsInIsolationReturnsTrue()
|
||||
{
|
||||
$test = new IsolationTest('testIsInIsolationReturnsTrue');
|
||||
$test->setRunTestInSeparateProcess(true);
|
||||
$result = $test->run();
|
||||
|
||||
$this->assertEquals(1, count($result));
|
||||
$this->assertTrue($result->wasSuccessful());
|
||||
}
|
||||
|
||||
public function testExpectOutputStringFooActualFoo()
|
||||
{
|
||||
$test = new OutputTestCase('testExpectOutputStringFooActualFoo');
|
||||
$result = $test->run();
|
||||
|
||||
$this->assertEquals(1, count($result));
|
||||
$this->assertTrue($result->wasSuccessful());
|
||||
}
|
||||
|
||||
public function testExpectOutputStringFooActualBar()
|
||||
{
|
||||
$test = new OutputTestCase('testExpectOutputStringFooActualBar');
|
||||
$result = $test->run();
|
||||
|
||||
$this->assertEquals(1, count($result));
|
||||
$this->assertFalse($result->wasSuccessful());
|
||||
}
|
||||
|
||||
public function testExpectOutputRegexFooActualFoo()
|
||||
{
|
||||
$test = new OutputTestCase('testExpectOutputRegexFooActualFoo');
|
||||
$result = $test->run();
|
||||
|
||||
$this->assertEquals(1, count($result));
|
||||
$this->assertTrue($result->wasSuccessful());
|
||||
}
|
||||
|
||||
public function testExpectOutputRegexFooActualBar()
|
||||
{
|
||||
$test = new OutputTestCase('testExpectOutputRegexFooActualBar');
|
||||
$result = $test->run();
|
||||
|
||||
$this->assertEquals(1, count($result));
|
||||
$this->assertFalse($result->wasSuccessful());
|
||||
}
|
||||
|
||||
public function testSkipsIfRequiresHigherVersionOfPHPUnit()
|
||||
{
|
||||
$test = new RequirementsTest('testAlwaysSkip');
|
||||
$result = $test->run();
|
||||
|
||||
$this->assertEquals(1, $result->skippedCount());
|
||||
$this->assertEquals(
|
||||
'PHPUnit 1111111 (or later) is required.',
|
||||
$test->getStatusMessage()
|
||||
);
|
||||
}
|
||||
|
||||
public function testSkipsIfRequiresHigherVersionOfPHP()
|
||||
{
|
||||
$test = new RequirementsTest('testAlwaysSkip2');
|
||||
$result = $test->run();
|
||||
|
||||
$this->assertEquals(1, $result->skippedCount());
|
||||
$this->assertEquals(
|
||||
'PHP 9999999 (or later) is required.',
|
||||
$test->getStatusMessage()
|
||||
);
|
||||
}
|
||||
|
||||
public function testSkipsIfRequiresNonExistingOs()
|
||||
{
|
||||
$test = new RequirementsTest('testAlwaysSkip3');
|
||||
$result = $test->run();
|
||||
|
||||
$this->assertEquals(1, $result->skippedCount());
|
||||
$this->assertEquals(
|
||||
'Operating system matching /DOESNOTEXIST/i is required.',
|
||||
$test->getStatusMessage()
|
||||
);
|
||||
}
|
||||
|
||||
public function testSkipsIfRequiresNonExistingFunction()
|
||||
{
|
||||
$test = new RequirementsTest('testNine');
|
||||
$result = $test->run();
|
||||
|
||||
$this->assertEquals(1, $result->skippedCount());
|
||||
$this->assertEquals(
|
||||
'Function testFunc is required.',
|
||||
$test->getStatusMessage()
|
||||
);
|
||||
}
|
||||
|
||||
public function testSkipsIfRequiresNonExistingExtension()
|
||||
{
|
||||
$test = new RequirementsTest('testTen');
|
||||
$result = $test->run();
|
||||
|
||||
$this->assertEquals(
|
||||
'Extension testExt is required.',
|
||||
$test->getStatusMessage()
|
||||
);
|
||||
}
|
||||
|
||||
public function testSkipsProvidesMessagesForAllSkippingReasons()
|
||||
{
|
||||
$test = new RequirementsTest('testAllPossibleRequirements');
|
||||
$result = $test->run();
|
||||
|
||||
$this->assertEquals(
|
||||
'PHP 99-dev (or later) is required.' . PHP_EOL .
|
||||
'PHPUnit 9-dev (or later) is required.' . PHP_EOL .
|
||||
'Operating system matching /DOESNOTEXIST/i is required.' . PHP_EOL .
|
||||
'Function testFuncOne is required.' . PHP_EOL .
|
||||
'Function testFuncTwo is required.' . PHP_EOL .
|
||||
'Extension testExtOne is required.' . PHP_EOL .
|
||||
'Extension testExtTwo is required.',
|
||||
$test->getStatusMessage()
|
||||
);
|
||||
}
|
||||
|
||||
public function testRequiringAnExistingMethodDoesNotSkip()
|
||||
{
|
||||
$test = new RequirementsTest('testExistingMethod');
|
||||
$result = $test->run();
|
||||
$this->assertEquals(0, $result->skippedCount());
|
||||
}
|
||||
|
||||
public function testRequiringAnExistingFunctionDoesNotSkip()
|
||||
{
|
||||
$test = new RequirementsTest('testExistingFunction');
|
||||
$result = $test->run();
|
||||
$this->assertEquals(0, $result->skippedCount());
|
||||
}
|
||||
|
||||
public function testRequiringAnExistingExtensionDoesNotSkip()
|
||||
{
|
||||
$test = new RequirementsTest('testExistingExtension');
|
||||
$result = $test->run();
|
||||
$this->assertEquals(0, $result->skippedCount());
|
||||
}
|
||||
|
||||
public function testRequiringAnExistingOsDoesNotSkip()
|
||||
{
|
||||
$test = new RequirementsTest('testExistingOs');
|
||||
$result = $test->run();
|
||||
$this->assertEquals(0, $result->skippedCount());
|
||||
}
|
||||
|
||||
public function testCurrentWorkingDirectoryIsRestored()
|
||||
{
|
||||
$expectedCwd = getcwd();
|
||||
|
||||
$test = new ChangeCurrentWorkingDirectoryTest('testSomethingThatChangesTheCwd');
|
||||
$test->run();
|
||||
|
||||
$this->assertSame($expectedCwd, getcwd());
|
||||
}
|
||||
|
||||
/**
|
||||
* @requires PHP 7
|
||||
* @expectedException TypeError
|
||||
*/
|
||||
public function testTypeErrorCanBeExpected()
|
||||
{
|
||||
$o = new ClassWithScalarTypeDeclarations;
|
||||
$o->foo(null, null);
|
||||
}
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @since File available since Release 3.7.20
|
||||
*/
|
||||
class Framework_TestFailureTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @covers PHPUnit_Framework_TestFailure::toString
|
||||
*/
|
||||
public function testToString()
|
||||
{
|
||||
$test = new self(__FUNCTION__);
|
||||
$exception = new PHPUnit_Framework_Exception('message');
|
||||
$failure = new PHPUnit_Framework_TestFailure($test, $exception);
|
||||
|
||||
$this->assertEquals(__METHOD__ . ': message', $failure->toString());
|
||||
}
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @since Class available since Release 2.0.0
|
||||
*/
|
||||
class Framework_TestImplementorTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @covers PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testSuccessfulRun()
|
||||
{
|
||||
$result = new PHPUnit_Framework_TestResult;
|
||||
|
||||
$test = new DoubleTestCase(new Success);
|
||||
$test->run($result);
|
||||
|
||||
$this->assertEquals(count($test), count($result));
|
||||
$this->assertEquals(0, $result->errorCount());
|
||||
$this->assertEquals(0, $result->failureCount());
|
||||
}
|
||||
}
|
|
@ -1,108 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @since Class available since Release 2.0.0
|
||||
* @covers PHPUnit_Framework_TestCase
|
||||
*/
|
||||
class Framework_TestListenerTest extends PHPUnit_Framework_TestCase implements PHPUnit_Framework_TestListener
|
||||
{
|
||||
protected $endCount;
|
||||
protected $errorCount;
|
||||
protected $failureCount;
|
||||
protected $notImplementedCount;
|
||||
protected $riskyCount;
|
||||
protected $skippedCount;
|
||||
protected $result;
|
||||
protected $startCount;
|
||||
|
||||
public function addError(PHPUnit_Framework_Test $test, Exception $e, $time)
|
||||
{
|
||||
$this->errorCount++;
|
||||
}
|
||||
|
||||
public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time)
|
||||
{
|
||||
$this->failureCount++;
|
||||
}
|
||||
|
||||
public function addIncompleteTest(PHPUnit_Framework_Test $test, Exception $e, $time)
|
||||
{
|
||||
$this->notImplementedCount++;
|
||||
}
|
||||
|
||||
public function addRiskyTest(PHPUnit_Framework_Test $test, Exception $e, $time)
|
||||
{
|
||||
$this->riskyCount++;
|
||||
}
|
||||
|
||||
public function addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, $time)
|
||||
{
|
||||
$this->skippedCount++;
|
||||
}
|
||||
|
||||
public function startTestSuite(PHPUnit_Framework_TestSuite $suite)
|
||||
{
|
||||
}
|
||||
|
||||
public function endTestSuite(PHPUnit_Framework_TestSuite $suite)
|
||||
{
|
||||
}
|
||||
|
||||
public function startTest(PHPUnit_Framework_Test $test)
|
||||
{
|
||||
$this->startCount++;
|
||||
}
|
||||
|
||||
public function endTest(PHPUnit_Framework_Test $test, $time)
|
||||
{
|
||||
$this->endCount++;
|
||||
}
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->result = new PHPUnit_Framework_TestResult;
|
||||
$this->result->addListener($this);
|
||||
|
||||
$this->endCount = 0;
|
||||
$this->failureCount = 0;
|
||||
$this->notImplementedCount = 0;
|
||||
$this->riskyCount = 0;
|
||||
$this->skippedCount = 0;
|
||||
$this->startCount = 0;
|
||||
}
|
||||
|
||||
public function testError()
|
||||
{
|
||||
$test = new TestError;
|
||||
$test->run($this->result);
|
||||
|
||||
$this->assertEquals(1, $this->errorCount);
|
||||
$this->assertEquals(1, $this->endCount);
|
||||
}
|
||||
|
||||
public function testFailure()
|
||||
{
|
||||
$test = new Failure;
|
||||
$test->run($this->result);
|
||||
|
||||
$this->assertEquals(1, $this->failureCount);
|
||||
$this->assertEquals(1, $this->endCount);
|
||||
}
|
||||
|
||||
public function testStartStop()
|
||||
{
|
||||
$test = new Success;
|
||||
$test->run($this->result);
|
||||
|
||||
$this->assertEquals(1, $this->startCount);
|
||||
$this->assertEquals(1, $this->endCount);
|
||||
}
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
--TEST--
|
||||
#1021: Depending on a test that uses a data provider does not work
|
||||
--FILE--
|
||||
<?php
|
||||
$_SERVER['argv'][1] = '--no-configuration';
|
||||
$_SERVER['argv'][2] = 'Issue1021Test';
|
||||
$_SERVER['argv'][3] = dirname(__FILE__) . '/1021/Issue1021Test.php';
|
||||
|
||||
require __DIR__ . '/../bootstrap.php';
|
||||
PHPUnit_TextUI_Command::main();
|
||||
?>
|
||||
--EXPECTF--
|
||||
PHPUnit %s by Sebastian Bergmann and contributors.
|
||||
|
||||
..
|
||||
|
||||
Time: %s, Memory: %sMb
|
||||
|
||||
OK (2 tests, 1 assertion)
|
|
@ -1,23 +0,0 @@
|
|||
<?php
|
||||
class Issue1021Test extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider provider
|
||||
*/
|
||||
public function testSomething($data)
|
||||
{
|
||||
$this->assertTrue($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testSomething
|
||||
*/
|
||||
public function testSomethingElse()
|
||||
{
|
||||
}
|
||||
|
||||
public function provider()
|
||||
{
|
||||
return array(array(true));
|
||||
}
|
||||
}
|
19
vendor/phpunit/phpunit/tests/Regression/523.phpt
vendored
19
vendor/phpunit/phpunit/tests/Regression/523.phpt
vendored
|
@ -1,19 +0,0 @@
|
|||
--TEST--
|
||||
#523: assertAttributeEquals does not work with classes extending ArrayIterator
|
||||
--FILE--
|
||||
<?php
|
||||
$_SERVER['argv'][1] = '--no-configuration';
|
||||
$_SERVER['argv'][2] = 'Issue523Test';
|
||||
$_SERVER['argv'][3] = dirname(__FILE__) . '/523/Issue523Test.php';
|
||||
|
||||
require __DIR__ . '/../bootstrap.php';
|
||||
PHPUnit_TextUI_Command::main();
|
||||
?>
|
||||
--EXPECTF--
|
||||
PHPUnit %s by Sebastian Bergmann and contributors.
|
||||
|
||||
.
|
||||
|
||||
Time: %s, Memory: %sMb
|
||||
|
||||
OK (1 test, 1 assertion)
|
|
@ -1,13 +0,0 @@
|
|||
<?php
|
||||
class Issue523Test extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testAttributeEquals()
|
||||
{
|
||||
$this->assertAttributeEquals('foo', 'field', new Issue523());
|
||||
}
|
||||
};
|
||||
|
||||
class Issue523 extends ArrayIterator
|
||||
{
|
||||
protected $field = 'foo';
|
||||
}
|
37
vendor/phpunit/phpunit/tests/Regression/578.phpt
vendored
37
vendor/phpunit/phpunit/tests/Regression/578.phpt
vendored
|
@ -1,37 +0,0 @@
|
|||
--TEST--
|
||||
#578: Double printing of trace line for exceptions from notices and warnings
|
||||
--FILE--
|
||||
<?php
|
||||
$_SERVER['argv'][1] = '--no-configuration';
|
||||
$_SERVER['argv'][2] = 'Issue578Test';
|
||||
$_SERVER['argv'][3] = dirname(__FILE__) . '/578/Issue578Test.php';
|
||||
|
||||
require __DIR__ . '/../bootstrap.php';
|
||||
PHPUnit_TextUI_Command::main();
|
||||
?>
|
||||
--EXPECTF--
|
||||
PHPUnit %s by Sebastian Bergmann and contributors.
|
||||
|
||||
EEE
|
||||
|
||||
Time: %s, Memory: %sMb
|
||||
|
||||
There were 3 errors:
|
||||
|
||||
1) Issue578Test::testNoticesDoublePrintStackTrace
|
||||
Invalid error type specified
|
||||
|
||||
%sIssue578Test.php:%i
|
||||
|
||||
2) Issue578Test::testWarningsDoublePrintStackTrace
|
||||
Invalid error type specified
|
||||
|
||||
%sIssue578Test.php:%i
|
||||
|
||||
3) Issue578Test::testUnexpectedExceptionsPrintsCorrectly
|
||||
Exception: Double printed exception
|
||||
|
||||
%sIssue578Test.php:%i
|
||||
|
||||
FAILURES!
|
||||
Tests: 3, Assertions: 0, Errors: 3.
|
|
@ -1,20 +0,0 @@
|
|||
<?php
|
||||
class Issue578Test extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testNoticesDoublePrintStackTrace()
|
||||
{
|
||||
$this->iniSet('error_reporting', E_ALL | E_NOTICE);
|
||||
trigger_error('Stack Trace Test Notice', E_NOTICE);
|
||||
}
|
||||
|
||||
public function testWarningsDoublePrintStackTrace()
|
||||
{
|
||||
$this->iniSet('error_reporting', E_ALL | E_NOTICE);
|
||||
trigger_error('Stack Trace Test Notice', E_WARNING);
|
||||
}
|
||||
|
||||
public function testUnexpectedExceptionsPrintsCorrectly()
|
||||
{
|
||||
throw new Exception('Double printed exception');
|
||||
}
|
||||
}
|
25
vendor/phpunit/phpunit/tests/Regression/684.phpt
vendored
25
vendor/phpunit/phpunit/tests/Regression/684.phpt
vendored
|
@ -1,25 +0,0 @@
|
|||
--TEST--
|
||||
#684: Unable to find test class when no test methods exists
|
||||
--FILE--
|
||||
<?php
|
||||
$_SERVER['argv'][1] = '--no-configuration';
|
||||
$_SERVER['argv'][2] = 'Issue684Test';
|
||||
$_SERVER['argv'][3] = dirname(__FILE__) . '/684/Issue684Test.php';
|
||||
|
||||
require __DIR__ . '/../bootstrap.php';
|
||||
PHPUnit_TextUI_Command::main();
|
||||
?>
|
||||
--EXPECTF--
|
||||
PHPUnit %s by Sebastian Bergmann and contributors.
|
||||
|
||||
F
|
||||
|
||||
Time: %s, Memory: %sMb
|
||||
|
||||
There was 1 failure:
|
||||
|
||||
1) Warning
|
||||
No tests found in class "Foo_Bar_Issue684Test".
|
||||
|
||||
FAILURES!
|
||||
Tests: 1, Assertions: 0, Failures: 1.
|
|
@ -1,4 +0,0 @@
|
|||
<?php
|
||||
class Foo_Bar_Issue684Test extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
}
|
21
vendor/phpunit/phpunit/tests/Regression/783.phpt
vendored
21
vendor/phpunit/phpunit/tests/Regression/783.phpt
vendored
|
@ -1,21 +0,0 @@
|
|||
--TEST--
|
||||
#783: Tests getting executed twice when using multiple groups
|
||||
--FILE--
|
||||
<?php
|
||||
$_SERVER['argv'][1] = '--no-configuration';
|
||||
$_SERVER['argv'][2] = '--group';
|
||||
$_SERVER['argv'][3] = 'foo,bar';
|
||||
$_SERVER['argv'][4] = 'ParentSuite';
|
||||
$_SERVER['argv'][5] = dirname(__FILE__) . '/783/ParentSuite.php';
|
||||
|
||||
require __DIR__ . '/../bootstrap.php';
|
||||
PHPUnit_TextUI_Command::main();
|
||||
?>
|
||||
--EXPECTF--
|
||||
PHPUnit %s by Sebastian Bergmann and contributors.
|
||||
|
||||
..
|
||||
|
||||
Time: %s, Memory: %sMb
|
||||
|
||||
OK (2 tests, 0 assertions)
|
|
@ -1,15 +0,0 @@
|
|||
<?php
|
||||
require_once 'OneTest.php';
|
||||
require_once 'TwoTest.php';
|
||||
|
||||
class ChildSuite
|
||||
{
|
||||
public static function suite()
|
||||
{
|
||||
$suite = new PHPUnit_Framework_TestSuite('Child');
|
||||
$suite->addTestSuite('OneTest');
|
||||
$suite->addTestSuite('TwoTest');
|
||||
|
||||
return $suite;
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Reference in a new issue