From 72d2b6f723fb5462264fed31a4d7a8e3799d2f79 Mon Sep 17 00:00:00 2001 From: Bernhard Posselt Date: Thu, 29 Jan 2015 20:33:05 +0100 Subject: additional inheritance tests --- .../utility/ControllerMethodReflectorTest.php | 46 +++++++++++++++++++++- 1 file changed, 44 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/lib/appframework/utility/ControllerMethodReflectorTest.php b/tests/lib/appframework/utility/ControllerMethodReflectorTest.php index cd6bd57da4c..2208875b359 100644 --- a/tests/lib/appframework/utility/ControllerMethodReflectorTest.php +++ b/tests/lib/appframework/utility/ControllerMethodReflectorTest.php @@ -25,6 +25,31 @@ namespace OC\AppFramework\Utility; +class BaseController { + + /** + * @Annotation + */ + public function test(){} + + /** + * @Annotation + */ + public function test2(){} + +} + +class MiddleController extends BaseController { + + /** + * @NoAnnotation + */ + public function test2() {} + +} + +class EndController extends MiddleController {} + class ControllerMethodReflectorTest extends \Test\TestCase { @@ -96,7 +121,7 @@ class ControllerMethodReflectorTest extends \Test\TestCase { 'arguments' ); - $this->assertEquals(array('arg' => null, 'arg2' => 'hi'), $reader->getParameters()); + $this->assertEquals(array('arg' => null, 'arg2' => 'hi'), $reader->getParameters()); } @@ -108,7 +133,24 @@ class ControllerMethodReflectorTest extends \Test\TestCase { 'arguments2' ); - $this->assertEquals(array('arg' => null), $reader->getParameters()); + $this->assertEquals(array('arg' => null), $reader->getParameters()); + } + + + public function testInheritance() { + $reader = new ControllerMethodReflector(); + $reader->reflect('OC\AppFramework\Utility\EndController', 'test'); + + $this->assertTrue($reader->hasAnnotation('Annotation')); + } + + + public function testInheritanceOverride() { + $reader = new ControllerMethodReflector(); + $reader->reflect('OC\AppFramework\Utility\EndController', 'test2'); + + $this->assertTrue($reader->hasAnnotation('NoAnnotation')); + $this->assertFalse($reader->hasAnnotation('Annotation')); } -- cgit v1.2.3 From 81836ccc7e19289d401ab9def6b8f467ed6e20f5 Mon Sep 17 00:00:00 2001 From: Bernhard Posselt Date: Thu, 29 Jan 2015 20:35:07 +0100 Subject: another test for overriding the docblock --- .../appframework/utility/ControllerMethodReflectorTest.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'tests') diff --git a/tests/lib/appframework/utility/ControllerMethodReflectorTest.php b/tests/lib/appframework/utility/ControllerMethodReflectorTest.php index 2208875b359..c513e23cd6b 100644 --- a/tests/lib/appframework/utility/ControllerMethodReflectorTest.php +++ b/tests/lib/appframework/utility/ControllerMethodReflectorTest.php @@ -37,6 +37,11 @@ class BaseController { */ public function test2(){} + /** + * @Annotation + */ + public function test3(){} + } class MiddleController extends BaseController { @@ -46,6 +51,8 @@ class MiddleController extends BaseController { */ public function test2() {} + public function test3() {} + } class EndController extends MiddleController {} @@ -154,4 +161,11 @@ class ControllerMethodReflectorTest extends \Test\TestCase { } + public function testInheritanceOverrideNoDocblock() { + $reader = new ControllerMethodReflector(); + $reader->reflect('OC\AppFramework\Utility\EndController', 'test3'); + + $this->assertFalse($reader->hasAnnotation('Annotation')); + } + } -- cgit v1.2.3