From 80a1e00d6ef8611c8dad9224c39b5cd1144490d4 Mon Sep 17 00:00:00 2001 From: Chris Wilkinson Date: Sat, 13 Oct 2018 20:43:30 +0100 Subject: [PATCH] Update GetMethodPropertiesTest --- tests/Core/File/GetMethodPropertiesTest.inc | 5 +++ tests/Core/File/GetMethodPropertiesTest.php | 48 +++++++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/tests/Core/File/GetMethodPropertiesTest.inc b/tests/Core/File/GetMethodPropertiesTest.inc index 2aad32dfe3..dd51e2c008 100644 --- a/tests/Core/File/GetMethodPropertiesTest.inc +++ b/tests/Core/File/GetMethodPropertiesTest.inc @@ -55,3 +55,8 @@ abstract class MyClass abstract protected function myFunction(): bool; } +interface MyInterface +{ + /* testInterfaceMethod */ + function myFunction(); +} diff --git a/tests/Core/File/GetMethodPropertiesTest.php b/tests/Core/File/GetMethodPropertiesTest.php index 697be36422..036095f6b0 100644 --- a/tests/Core/File/GetMethodPropertiesTest.php +++ b/tests/Core/File/GetMethodPropertiesTest.php @@ -74,6 +74,7 @@ public function testBasicFunction() 'is_abstract' => false, 'is_final' => false, 'is_static' => false, + 'has_body' => true, ]; $start = ($this->phpcsFile->numTokens - 1); @@ -107,6 +108,7 @@ public function testReturnFunction() 'is_abstract' => false, 'is_final' => false, 'is_static' => false, + 'has_body' => true, ]; $start = ($this->phpcsFile->numTokens - 1); @@ -140,6 +142,7 @@ public function testNestedClosure() 'is_abstract' => false, 'is_final' => false, 'is_static' => false, + 'has_body' => true, ]; $start = ($this->phpcsFile->numTokens - 1); @@ -173,6 +176,7 @@ public function testBasicMethod() 'is_abstract' => false, 'is_final' => false, 'is_static' => false, + 'has_body' => true, ]; $start = ($this->phpcsFile->numTokens - 1); @@ -206,6 +210,7 @@ public function testPrivateStaticMethod() 'is_abstract' => false, 'is_final' => false, 'is_static' => true, + 'has_body' => true, ]; $start = ($this->phpcsFile->numTokens - 1); @@ -239,6 +244,7 @@ public function testFinalMethod() 'is_abstract' => false, 'is_final' => true, 'is_static' => false, + 'has_body' => true, ]; $start = ($this->phpcsFile->numTokens - 1); @@ -272,6 +278,7 @@ public function testProtectedReturnMethod() 'is_abstract' => false, 'is_final' => false, 'is_static' => false, + 'has_body' => true, ]; $start = ($this->phpcsFile->numTokens - 1); @@ -305,6 +312,7 @@ public function testPublicReturnMethod() 'is_abstract' => false, 'is_final' => false, 'is_static' => false, + 'has_body' => true, ]; $start = ($this->phpcsFile->numTokens - 1); @@ -338,6 +346,7 @@ public function testNullableReturnMethod() 'is_abstract' => false, 'is_final' => false, 'is_static' => false, + 'has_body' => true, ]; $start = ($this->phpcsFile->numTokens - 1); @@ -371,6 +380,7 @@ public function testMessyNullableReturnMethod() 'is_abstract' => false, 'is_final' => false, 'is_static' => false, + 'has_body' => true, ]; $start = ($this->phpcsFile->numTokens - 1); @@ -404,6 +414,7 @@ public function testReturnNamespace() 'is_abstract' => false, 'is_final' => false, 'is_static' => false, + 'has_body' => true, ]; $start = ($this->phpcsFile->numTokens - 1); @@ -437,6 +448,7 @@ public function testReturnMultilineNamespace() 'is_abstract' => false, 'is_final' => false, 'is_static' => false, + 'has_body' => true, ]; $start = ($this->phpcsFile->numTokens - 1); @@ -470,6 +482,7 @@ public function testAbstractMethod() 'is_abstract' => true, 'is_final' => false, 'is_static' => false, + 'has_body' => false, ]; $start = ($this->phpcsFile->numTokens - 1); @@ -503,6 +516,7 @@ public function testAbstractReturnMethod() 'is_abstract' => true, 'is_final' => false, 'is_static' => false, + 'has_body' => false, ]; $start = ($this->phpcsFile->numTokens - 1); @@ -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