updated-packages
This commit is contained in:
@@ -24,9 +24,7 @@ class PHP_Token_ClassTest extends TestCase
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$ts = new PHP_Token_Stream(TEST_FILES_PATH . 'source2.php');
|
||||
|
||||
foreach ($ts as $token) {
|
||||
foreach (new PHP_Token_Stream(TEST_FILES_PATH . 'source2.php') as $token) {
|
||||
if ($token instanceof PHP_Token_CLASS) {
|
||||
$this->class = $token;
|
||||
}
|
||||
@@ -38,25 +36,16 @@ class PHP_Token_ClassTest extends TestCase
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @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());
|
||||
@@ -64,9 +53,7 @@ class PHP_Token_ClassTest extends TestCase
|
||||
|
||||
public function testIssue19()
|
||||
{
|
||||
$ts = new PHP_Token_Stream(TEST_FILES_PATH . 'issue19.php');
|
||||
|
||||
foreach ($ts as $token) {
|
||||
foreach (new PHP_Token_Stream(TEST_FILES_PATH . 'issue19.php') as $token) {
|
||||
if ($token instanceof PHP_Token_CLASS) {
|
||||
$this->assertFalse($token->hasInterfaces());
|
||||
}
|
||||
@@ -143,9 +130,7 @@ class PHP_Token_ClassTest extends TestCase
|
||||
*/
|
||||
public function testClassWithMethodNamedEmptyIsHandledCorrectly()
|
||||
{
|
||||
$ts = new PHP_Token_Stream(TEST_FILES_PATH . 'class_with_method_named_empty.php');
|
||||
|
||||
$classes = $ts->getClasses();
|
||||
$classes = (new PHP_Token_Stream(TEST_FILES_PATH . 'class_with_method_named_empty.php'))->getClasses();
|
||||
|
||||
$this->assertArrayHasKey('class_with_method_named_empty', $classes);
|
||||
$this->assertArrayHasKey('empty', $classes['class_with_method_named_empty']['methods']);
|
||||
@@ -156,9 +141,7 @@ class PHP_Token_ClassTest extends TestCase
|
||||
*/
|
||||
public function testAnonymousFunctionDoesNotAffectStartAndEndLineOfMethod()
|
||||
{
|
||||
$ts = new PHP_Token_Stream(TEST_FILES_PATH . 'php-code-coverage-issue-424.php');
|
||||
|
||||
$classes = $ts->getClasses();
|
||||
$classes = (new PHP_Token_Stream(TEST_FILES_PATH . 'php-code-coverage-issue-424.php'))->getClasses();
|
||||
|
||||
$this->assertSame(5, $classes['Example']['methods']['even']['startLine']);
|
||||
$this->assertSame(12, $classes['Example']['methods']['even']['endLine']);
|
||||
|
||||
@@ -19,18 +19,13 @@ class PHP_Token_ClosureTest extends TestCase
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$ts = new PHP_Token_Stream(TEST_FILES_PATH . 'closure.php');
|
||||
|
||||
foreach ($ts as $token) {
|
||||
foreach (new PHP_Token_Stream(TEST_FILES_PATH . 'closure.php') as $token) {
|
||||
if ($token instanceof PHP_Token_FUNCTION) {
|
||||
$this->functions[] = $token;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_Token_FUNCTION::getArguments
|
||||
*/
|
||||
public function testGetArguments()
|
||||
{
|
||||
$this->assertEquals(['$foo' => null, '$bar' => null], $this->functions[0]->getArguments());
|
||||
@@ -41,9 +36,6 @@ class PHP_Token_ClosureTest extends TestCase
|
||||
$this->assertEquals([], $this->functions[5]->getArguments());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_Token_FUNCTION::getName
|
||||
*/
|
||||
public function testGetName()
|
||||
{
|
||||
$this->assertEquals('anonymousFunction:2#5', $this->functions[0]->getName());
|
||||
@@ -54,9 +46,6 @@ class PHP_Token_ClosureTest extends TestCase
|
||||
$this->assertEquals('anonymousFunction:7#106', $this->functions[5]->getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_Token::getLine
|
||||
*/
|
||||
public function testGetLine()
|
||||
{
|
||||
$this->assertEquals(2, $this->functions[0]->getLine());
|
||||
@@ -65,9 +54,6 @@ class PHP_Token_ClosureTest extends TestCase
|
||||
$this->assertEquals(5, $this->functions[3]->getLine());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_TokenWithScope::getEndLine
|
||||
*/
|
||||
public function testGetEndLine()
|
||||
{
|
||||
$this->assertEquals(2, $this->functions[0]->getLine());
|
||||
|
||||
@@ -19,32 +19,27 @@ class PHP_Token_FunctionTest extends TestCase
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$ts = new PHP_Token_Stream(TEST_FILES_PATH . 'source.php');
|
||||
|
||||
foreach ($ts as $token) {
|
||||
foreach (new PHP_Token_Stream(TEST_FILES_PATH . 'source.php') as $token) {
|
||||
if ($token instanceof PHP_Token_FUNCTION) {
|
||||
$this->functions[] = $token;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_Token_FUNCTION::getArguments
|
||||
*/
|
||||
public function testGetArguments()
|
||||
{
|
||||
$this->assertEquals([], $this->functions[0]->getArguments());
|
||||
|
||||
$this->assertEquals(
|
||||
['$baz' => 'Baz'], $this->functions[1]->getArguments()
|
||||
['$baz' => 'Baz'], $this->functions[1]->getArguments()
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
['$foobar' => 'Foobar'], $this->functions[2]->getArguments()
|
||||
['$foobar' => 'Foobar'], $this->functions[2]->getArguments()
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
['$barfoo' => 'Barfoo'], $this->functions[3]->getArguments()
|
||||
['$barfoo' => 'Barfoo'], $this->functions[3]->getArguments()
|
||||
);
|
||||
|
||||
$this->assertEquals([], $this->functions[4]->getArguments());
|
||||
@@ -52,9 +47,6 @@ class PHP_Token_FunctionTest extends TestCase
|
||||
$this->assertEquals(['$x' => null, '$y' => null], $this->functions[5]->getArguments());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_Token_FUNCTION::getName
|
||||
*/
|
||||
public function testGetName()
|
||||
{
|
||||
$this->assertEquals('foo', $this->functions[0]->getName());
|
||||
@@ -64,9 +56,6 @@ class PHP_Token_FunctionTest extends TestCase
|
||||
$this->assertEquals('baz', $this->functions[4]->getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_Token::getLine
|
||||
*/
|
||||
public function testGetLine()
|
||||
{
|
||||
$this->assertEquals(5, $this->functions[0]->getLine());
|
||||
@@ -77,9 +66,6 @@ class PHP_Token_FunctionTest extends TestCase
|
||||
$this->assertEquals(37, $this->functions[6]->getLine());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_TokenWithScope::getEndLine
|
||||
*/
|
||||
public function testGetEndLine()
|
||||
{
|
||||
$this->assertEquals(5, $this->functions[0]->getEndLine());
|
||||
@@ -90,21 +76,18 @@ class PHP_Token_FunctionTest extends TestCase
|
||||
$this->assertEquals(41, $this->functions[6]->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()
|
||||
"/**\n * @param Baz \$baz\n */",
|
||||
$this->functions[1]->getDocblock()
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
"/**\n * @param Foobar \$foobar\n */",
|
||||
$this->functions[2]->getDocblock()
|
||||
"/**\n * @param Foobar \$foobar\n */",
|
||||
$this->functions[2]->getDocblock()
|
||||
);
|
||||
|
||||
$this->assertNull($this->functions[3]->getDocblock());
|
||||
@@ -113,29 +96,29 @@ class PHP_Token_FunctionTest extends TestCase
|
||||
|
||||
public function testSignature()
|
||||
{
|
||||
$ts = new PHP_Token_Stream(TEST_FILES_PATH . 'source5.php');
|
||||
$f = $ts->getFunctions();
|
||||
$c = $ts->getClasses();
|
||||
$i = $ts->getInterfaces();
|
||||
$tokens = new PHP_Token_Stream(TEST_FILES_PATH . 'source5.php');
|
||||
$functions = $tokens->getFunctions();
|
||||
$classes = $tokens->getClasses();
|
||||
$interfaces = $tokens->getInterfaces();
|
||||
|
||||
$this->assertEquals(
|
||||
'foo($a, array $b, array $c = array())',
|
||||
$f['foo']['signature']
|
||||
'foo($a, array $b, array $c = array())',
|
||||
$functions['foo']['signature']
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
'm($a, array $b, array $c = array())',
|
||||
$c['c']['methods']['m']['signature']
|
||||
'm($a, array $b, array $c = array())',
|
||||
$classes['c']['methods']['m']['signature']
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
'm($a, array $b, array $c = array())',
|
||||
$c['a']['methods']['m']['signature']
|
||||
'm($a, array $b, array $c = array())',
|
||||
$classes['a']['methods']['m']['signature']
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
'm($a, array $b, array $c = array())',
|
||||
$i['i']['methods']['m']['signature']
|
||||
'm($a, array $b, array $c = array())',
|
||||
$interfaces['i']['methods']['m']['signature']
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,44 +22,32 @@ class PHP_Token_IncludeTest extends TestCase
|
||||
$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(
|
||||
['test4.php', 'test3.php', 'test2.php', 'test1.php'],
|
||||
$this->ts->getIncludes()
|
||||
['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(
|
||||
[
|
||||
'require_once' => ['test4.php'],
|
||||
'require' => ['test3.php'],
|
||||
'include_once' => ['test2.php'],
|
||||
'include' => ['test1.php']
|
||||
],
|
||||
$this->ts->getIncludes(true)
|
||||
[
|
||||
'require_once' => ['test4.php'],
|
||||
'require' => ['test3.php'],
|
||||
'include_once' => ['test2.php'],
|
||||
'include' => ['test1.php']
|
||||
],
|
||||
$this->ts->getIncludes(true)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_Token_Includes::getName
|
||||
* @covers PHP_Token_Includes::getType
|
||||
*/
|
||||
public function testGetIncludesCategory()
|
||||
{
|
||||
$this->assertSame(
|
||||
['test4.php'],
|
||||
$this->ts->getIncludes(true, 'require_once')
|
||||
['test4.php'],
|
||||
$this->ts->getIncludes(true, 'require_once')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,9 +37,6 @@ class PHP_Token_InterfaceTest extends TestCase
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_Token_INTERFACE::getName
|
||||
*/
|
||||
public function testGetName()
|
||||
{
|
||||
$this->assertEquals(
|
||||
@@ -47,9 +44,6 @@ class PHP_Token_InterfaceTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_Token_INTERFACE::getParent
|
||||
*/
|
||||
public function testGetParentNotExists()
|
||||
{
|
||||
$this->assertFalse(
|
||||
@@ -57,9 +51,6 @@ class PHP_Token_InterfaceTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_Token_INTERFACE::hasParent
|
||||
*/
|
||||
public function testHasParentNotExists()
|
||||
{
|
||||
$this->assertFalse(
|
||||
@@ -67,9 +58,6 @@ class PHP_Token_InterfaceTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_Token_INTERFACE::getParent
|
||||
*/
|
||||
public function testGetParentExists()
|
||||
{
|
||||
$this->assertEquals(
|
||||
@@ -77,9 +65,6 @@ class PHP_Token_InterfaceTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_Token_INTERFACE::hasParent
|
||||
*/
|
||||
public function testHasParentExists()
|
||||
{
|
||||
$this->assertTrue(
|
||||
@@ -87,9 +72,6 @@ class PHP_Token_InterfaceTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_Token_INTERFACE::getInterfaces
|
||||
*/
|
||||
public function testGetInterfacesExists()
|
||||
{
|
||||
$this->assertEquals(
|
||||
@@ -98,9 +80,6 @@ class PHP_Token_InterfaceTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_Token_INTERFACE::hasInterfaces
|
||||
*/
|
||||
public function testHasInterfacesExists()
|
||||
{
|
||||
$this->assertTrue(
|
||||
@@ -108,13 +87,9 @@ class PHP_Token_InterfaceTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_Token_INTERFACE::getPackage
|
||||
*/
|
||||
public function testGetPackageNamespace()
|
||||
{
|
||||
$tokenStream = new PHP_Token_Stream(TEST_FILES_PATH . 'classInNamespace.php');
|
||||
foreach ($tokenStream as $token) {
|
||||
foreach (new PHP_Token_Stream(TEST_FILES_PATH . 'classInNamespace.php') as $token) {
|
||||
if ($token instanceof PHP_Token_INTERFACE) {
|
||||
$package = $token->getPackage();
|
||||
$this->assertSame('Foo\\Bar', $package['namespace']);
|
||||
@@ -122,7 +97,6 @@ class PHP_Token_InterfaceTest extends TestCase
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function provideFilesWithClassesWithinMultipleNamespaces()
|
||||
{
|
||||
return [
|
||||
@@ -133,12 +107,12 @@ class PHP_Token_InterfaceTest extends TestCase
|
||||
|
||||
/**
|
||||
* @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();
|
||||
@@ -167,13 +141,11 @@ class PHP_Token_InterfaceTest extends TestCase
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @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();
|
||||
@@ -182,6 +154,7 @@ class PHP_Token_InterfaceTest extends TestCase
|
||||
$firstClassFound = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($token instanceof PHP_Token_INTERFACE) {
|
||||
$package = $token->getPackage();
|
||||
$this->assertSame('Extender', $token->getName());
|
||||
@@ -190,6 +163,7 @@ class PHP_Token_InterfaceTest extends TestCase
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$this->fail('Searching for 2 classes failed');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,9 +12,6 @@ use PHPUnit\Framework\TestCase;
|
||||
|
||||
class PHP_Token_NamespaceTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @covers PHP_Token_NAMESPACE::getName
|
||||
*/
|
||||
public function testGetName()
|
||||
{
|
||||
$tokenStream = new PHP_Token_Stream(
|
||||
@@ -30,8 +27,7 @@ class PHP_Token_NamespaceTest extends TestCase
|
||||
|
||||
public function testGetStartLineWithUnscopedNamespace()
|
||||
{
|
||||
$tokenStream = new PHP_Token_Stream(TEST_FILES_PATH . 'classInNamespace.php');
|
||||
foreach ($tokenStream as $token) {
|
||||
foreach (new PHP_Token_Stream(TEST_FILES_PATH . 'classInNamespace.php') as $token) {
|
||||
if ($token instanceof PHP_Token_NAMESPACE) {
|
||||
$this->assertSame(2, $token->getLine());
|
||||
}
|
||||
@@ -40,8 +36,7 @@ class PHP_Token_NamespaceTest extends TestCase
|
||||
|
||||
public function testGetEndLineWithUnscopedNamespace()
|
||||
{
|
||||
$tokenStream = new PHP_Token_Stream(TEST_FILES_PATH . 'classInNamespace.php');
|
||||
foreach ($tokenStream as $token) {
|
||||
foreach (new PHP_Token_Stream(TEST_FILES_PATH . 'classInNamespace.php') as $token) {
|
||||
if ($token instanceof PHP_Token_NAMESPACE) {
|
||||
$this->assertSame(2, $token->getEndLine());
|
||||
}
|
||||
@@ -49,8 +44,7 @@ class PHP_Token_NamespaceTest extends TestCase
|
||||
}
|
||||
public function testGetStartLineWithScopedNamespace()
|
||||
{
|
||||
$tokenStream = new PHP_Token_Stream(TEST_FILES_PATH . 'classInScopedNamespace.php');
|
||||
foreach ($tokenStream as $token) {
|
||||
foreach (new PHP_Token_Stream(TEST_FILES_PATH . 'classInScopedNamespace.php') as $token) {
|
||||
if ($token instanceof PHP_Token_NAMESPACE) {
|
||||
$this->assertSame(2, $token->getLine());
|
||||
}
|
||||
@@ -59,8 +53,7 @@ class PHP_Token_NamespaceTest extends TestCase
|
||||
|
||||
public function testGetEndLineWithScopedNamespace()
|
||||
{
|
||||
$tokenStream = new PHP_Token_Stream(TEST_FILES_PATH . 'classInScopedNamespace.php');
|
||||
foreach ($tokenStream as $token) {
|
||||
foreach (new PHP_Token_Stream(TEST_FILES_PATH . 'classInScopedNamespace.php') as $token) {
|
||||
if ($token instanceof PHP_Token_NAMESPACE) {
|
||||
$this->assertSame(8, $token->getEndLine());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user