Skip to content

Commit

Permalink
Update GetMethodPropertiesTest
Browse files Browse the repository at this point in the history
  • Loading branch information
thewilkybarkid committed Oct 13, 2018
1 parent 2410463 commit 80a1e00
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tests/Core/File/GetMethodPropertiesTest.inc
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,8 @@ abstract class MyClass
abstract protected function myFunction(): bool;
}

interface MyInterface
{
/* testInterfaceMethod */
function myFunction();
}
48 changes: 48 additions & 0 deletions tests/Core/File/GetMethodPropertiesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public function testBasicFunction()
'is_abstract' => false,
'is_final' => false,
'is_static' => false,
'has_body' => true,
];

$start = ($this->phpcsFile->numTokens - 1);
Expand Down Expand Up @@ -107,6 +108,7 @@ public function testReturnFunction()
'is_abstract' => false,
'is_final' => false,
'is_static' => false,
'has_body' => true,
];

$start = ($this->phpcsFile->numTokens - 1);
Expand Down Expand Up @@ -140,6 +142,7 @@ public function testNestedClosure()
'is_abstract' => false,
'is_final' => false,
'is_static' => false,
'has_body' => true,
];

$start = ($this->phpcsFile->numTokens - 1);
Expand Down Expand Up @@ -173,6 +176,7 @@ public function testBasicMethod()
'is_abstract' => false,
'is_final' => false,
'is_static' => false,
'has_body' => true,
];

$start = ($this->phpcsFile->numTokens - 1);
Expand Down Expand Up @@ -206,6 +210,7 @@ public function testPrivateStaticMethod()
'is_abstract' => false,
'is_final' => false,
'is_static' => true,
'has_body' => true,
];

$start = ($this->phpcsFile->numTokens - 1);
Expand Down Expand Up @@ -239,6 +244,7 @@ public function testFinalMethod()
'is_abstract' => false,
'is_final' => true,
'is_static' => false,
'has_body' => true,
];

$start = ($this->phpcsFile->numTokens - 1);
Expand Down Expand Up @@ -272,6 +278,7 @@ public function testProtectedReturnMethod()
'is_abstract' => false,
'is_final' => false,
'is_static' => false,
'has_body' => true,
];

$start = ($this->phpcsFile->numTokens - 1);
Expand Down Expand Up @@ -305,6 +312,7 @@ public function testPublicReturnMethod()
'is_abstract' => false,
'is_final' => false,
'is_static' => false,
'has_body' => true,
];

$start = ($this->phpcsFile->numTokens - 1);
Expand Down Expand Up @@ -338,6 +346,7 @@ public function testNullableReturnMethod()
'is_abstract' => false,
'is_final' => false,
'is_static' => false,
'has_body' => true,
];

$start = ($this->phpcsFile->numTokens - 1);
Expand Down Expand Up @@ -371,6 +380,7 @@ public function testMessyNullableReturnMethod()
'is_abstract' => false,
'is_final' => false,
'is_static' => false,
'has_body' => true,
];

$start = ($this->phpcsFile->numTokens - 1);
Expand Down Expand Up @@ -404,6 +414,7 @@ public function testReturnNamespace()
'is_abstract' => false,
'is_final' => false,
'is_static' => false,
'has_body' => true,
];

$start = ($this->phpcsFile->numTokens - 1);
Expand Down Expand Up @@ -437,6 +448,7 @@ public function testReturnMultilineNamespace()
'is_abstract' => false,
'is_final' => false,
'is_static' => false,
'has_body' => true,
];

$start = ($this->phpcsFile->numTokens - 1);
Expand Down Expand Up @@ -470,6 +482,7 @@ public function testAbstractMethod()
'is_abstract' => true,
'is_final' => false,
'is_static' => false,
'has_body' => false,
];

$start = ($this->phpcsFile->numTokens - 1);
Expand Down Expand Up @@ -503,6 +516,7 @@ public function testAbstractReturnMethod()
'is_abstract' => true,
'is_final' => false,
'is_static' => false,
'has_body' => false,
];

$start = ($this->phpcsFile->numTokens - 1);
Expand All @@ -521,4 +535,38 @@ public function testAbstractReturnMethod()
}//end testAbstractReturnMethod()


/**
* Test a basic interface method.
*
* @return void
*/
public function testInterfaceMethod()
{
$expected = [
'scope' => 'public',
'scope_specified' => false,
'return_type' => '',
'nullable_return_type' => false,
'is_abstract' => false,
'is_final' => false,
'is_static' => false,
'has_body' => false,
];

$start = ($this->phpcsFile->numTokens - 1);
$function = $this->phpcsFile->findPrevious(
T_COMMENT,
$start,
null,
false,
'/* testInterfaceMethod */'
);

$found = $this->phpcsFile->getMethodProperties(($function + 3));
unset($found['return_type_token']);
$this->assertSame($expected, $found);

}//end testAbstractMethod()


}//end class

0 comments on commit 80a1e00

Please sign in to comment.