| @@ 13-39 (lines=27) @@ | ||
| 10 | * @copyright Copyright 2015 Fwolf |
|
| 11 | * @license http://www.gnu.org/licenses/lgpl.html LGPL-3.0+ |
|
| 12 | */ |
|
| 13 | class HandlerAwareTraitTest extends PHPUnitTestCase |
|
| 14 | { |
|
| 15 | /** |
|
| 16 | * @return MockObject | CacheHandlerAwareTrait |
|
| 17 | */ |
|
| 18 | protected function buildMock() |
|
| 19 | { |
|
| 20 | $mock = $this->getMockBuilder(CacheHandlerAwareTrait::class) |
|
| 21 | ->setMethods(null) |
|
| 22 | ->getMockForTrait(); |
|
| 23 | ||
| 24 | return $mock; |
|
| 25 | } |
|
| 26 | ||
| 27 | ||
| 28 | public function testSetAndGet() |
|
| 29 | { |
|
| 30 | $handlerAware = $this->buildMock(); |
|
| 31 | $cacheHandler = $this->getMock(CacheHandlerInterface::class); |
|
| 32 | ||
| 33 | $handlerAware->setCacheHandler($cacheHandler); |
|
| 34 | $this->assertInstanceOf( |
|
| 35 | CacheHandlerInterface::class, |
|
| 36 | $this->reflectionCall($handlerAware, 'getCacheHandler') |
|
| 37 | ); |
|
| 38 | } |
|
| 39 | } |
|
| 40 | ||
| @@ 13-40 (lines=28) @@ | ||
| 10 | * @copyright Copyright 2015 Fwolf |
|
| 11 | * @license http://www.gnu.org/licenses/lgpl.html LGPL-3.0+ |
|
| 12 | */ |
|
| 13 | class FormAwareTraitTest extends PHPUnitTestCase |
|
| 14 | { |
|
| 15 | /** |
|
| 16 | * @param string[] $methods |
|
| 17 | * @return MockObject|FormAwareTrait |
|
| 18 | */ |
|
| 19 | protected function buildMock(array $methods = null) |
|
| 20 | { |
|
| 21 | $mock = $this->getMockBuilder(FormAwareTrait::class) |
|
| 22 | ->setMethods($methods) |
|
| 23 | ->getMockForTrait(); |
|
| 24 | ||
| 25 | return $mock; |
|
| 26 | } |
|
| 27 | ||
| 28 | ||
| 29 | public function testAccessors() |
|
| 30 | { |
|
| 31 | /** @var MockObject|Form $form */ |
|
| 32 | $form = $this->getMockBuilder(Form::class) |
|
| 33 | ->getMock(); |
|
| 34 | ||
| 35 | $trait = $this->buildMock(); |
|
| 36 | ||
| 37 | $trait->setForm($form); |
|
| 38 | $this->assertInstanceOf(Form::class, $trait->getForm()); |
|
| 39 | } |
|
| 40 | } |
|
| 41 | ||
| @@ 13-39 (lines=27) @@ | ||
| 10 | * @copyright Copyright 2015 Fwolf |
|
| 11 | * @license http://www.gnu.org/licenses/lgpl.html LGPL-3.0+ |
|
| 12 | */ |
|
| 13 | class ListDtoAwareTraitTest extends PHPUnitTestCase |
|
| 14 | { |
|
| 15 | /** |
|
| 16 | * @return MockObject | ListDtoAwareTrait |
|
| 17 | */ |
|
| 18 | protected function buildMock() |
|
| 19 | { |
|
| 20 | $mock = $this->getMockBuilder(ListDtoAwareTrait::class) |
|
| 21 | ->setMethods(null) |
|
| 22 | ->getMockForTrait(); |
|
| 23 | ||
| 24 | return $mock; |
|
| 25 | } |
|
| 26 | ||
| 27 | ||
| 28 | public function test() |
|
| 29 | { |
|
| 30 | $listDtoAware = $this->buildMock(); |
|
| 31 | ||
| 32 | $listDto = new ListDto; |
|
| 33 | $listDtoAware->setListDto($listDto); |
|
| 34 | $this->assertInstanceOf( |
|
| 35 | ListDto::class, |
|
| 36 | $this->reflectionCall($listDtoAware, 'getListDto') |
|
| 37 | ); |
|
| 38 | } |
|
| 39 | } |
|
| 40 | ||
| @@ 14-41 (lines=28) @@ | ||
| 11 | * @copyright Copyright 2015 Fwolf |
|
| 12 | * @license http://www.gnu.org/licenses/lgpl.html LGPL-3.0+ |
|
| 13 | */ |
|
| 14 | class RendererAwareTraitTest extends PHPUnitTestCase |
|
| 15 | { |
|
| 16 | /** |
|
| 17 | * @return MockObject|RendererAwareTrait |
|
| 18 | */ |
|
| 19 | protected function buildMock() |
|
| 20 | { |
|
| 21 | $mock = $this->getMockBuilder(RendererAwareTrait::class) |
|
| 22 | ->setMethods(null) |
|
| 23 | ->getMockForTrait(); |
|
| 24 | ||
| 25 | return $mock; |
|
| 26 | } |
|
| 27 | ||
| 28 | ||
| 29 | public function test() |
|
| 30 | { |
|
| 31 | $rendererAware = $this->buildMock(); |
|
| 32 | ||
| 33 | /** @var MockObject|Renderer $renderer */ |
|
| 34 | $renderer = $this->getMock(Renderer::class); |
|
| 35 | $rendererAware->setRenderer($renderer); |
|
| 36 | $this->assertInstanceOf( |
|
| 37 | RendererInterface::class, |
|
| 38 | $this->reflectionCall($rendererAware, 'getRenderer') |
|
| 39 | ); |
|
| 40 | } |
|
| 41 | } |
|
| 42 | ||
| @@ 13-39 (lines=27) @@ | ||
| 10 | * @copyright Copyright 2015 Fwolf |
|
| 11 | * @license http://www.gnu.org/licenses/lgpl.html LGPL-3.0+ |
|
| 12 | */ |
|
| 13 | class RequestAwareTraitTest extends PHPUnitTestCase |
|
| 14 | { |
|
| 15 | /** |
|
| 16 | * @return MockObject | RequestAwareTrait |
|
| 17 | */ |
|
| 18 | protected function buildMock() |
|
| 19 | { |
|
| 20 | $mock = $this->getMockBuilder(RequestAwareTrait::class) |
|
| 21 | ->setMethods(null) |
|
| 22 | ->getMockForTrait(); |
|
| 23 | ||
| 24 | return $mock; |
|
| 25 | } |
|
| 26 | ||
| 27 | ||
| 28 | public function test() |
|
| 29 | { |
|
| 30 | $requestAware = $this->buildMock(); |
|
| 31 | ||
| 32 | $request = new Request; |
|
| 33 | $requestAware->setRequest($request); |
|
| 34 | $this->assertInstanceOf( |
|
| 35 | Request::class, |
|
| 36 | $this->reflectionCall($requestAware, 'getRequest') |
|
| 37 | ); |
|
| 38 | } |
|
| 39 | } |
|
| 40 | ||
| @@ 14-41 (lines=28) @@ | ||
| 11 | * @copyright Copyright 2015 Fwolf |
|
| 12 | * @license http://www.gnu.org/licenses/lgpl.html LGPL-3.0+ |
|
| 13 | */ |
|
| 14 | class RetrieverAwareTraitTest extends PHPUnitTestCase |
|
| 15 | { |
|
| 16 | /** |
|
| 17 | * @return MockObject | RetrieverAwareTrait |
|
| 18 | */ |
|
| 19 | protected function buildMock() |
|
| 20 | { |
|
| 21 | $mock = $this->getMockBuilder(RetrieverAwareTrait::class) |
|
| 22 | ->setMethods(null) |
|
| 23 | ->getMockForTrait(); |
|
| 24 | ||
| 25 | return $mock; |
|
| 26 | } |
|
| 27 | ||
| 28 | ||
| 29 | public function test() |
|
| 30 | { |
|
| 31 | $retrieverAware = $this->buildMock(); |
|
| 32 | ||
| 33 | /** @var MockObject|AbstractRetriever $retriever */ |
|
| 34 | $retriever = $this->getMock(AbstractRetriever::class); |
|
| 35 | $retrieverAware->setRetriever($retriever); |
|
| 36 | $this->assertInstanceOf( |
|
| 37 | RetrieverInterface::class, |
|
| 38 | $this->reflectionCall($retrieverAware, 'getRetriever') |
|
| 39 | ); |
|
| 40 | } |
|
| 41 | } |
|
| 42 | ||