| @@ 22-63 (lines=42) @@ | ||
| 19 | use Jolicht\MarkdownCms\Action\BlogOverviewActionFactory; |
|
| 20 | use Jolicht\MarkdownCms\Action\BlogOverviewAction; |
|
| 21 | ||
| 22 | class BlogOverviewActionFactoryTest extends ServiceManagerAwareTestCase |
|
| 23 | { |
|
| 24 | private $factory; |
|
| 25 | ||
| 26 | protected function setUp() |
|
| 27 | { |
|
| 28 | $this->setConfigProviders([ModuleConfig::class]); |
|
| 29 | parent::setUp(); |
|
| 30 | $this->factory = new BlogOverviewActionFactory(); |
|
| 31 | } |
|
| 32 | ||
| 33 | public function testContainerHasService() |
|
| 34 | { |
|
| 35 | $this->assertTrue($this->getContainer()->has(BlogOverviewAction::class)); |
|
| 36 | } |
|
| 37 | ||
| 38 | public function testCreateService() |
|
| 39 | { |
|
| 40 | $container = $this->getContainer(); |
|
| 41 | ||
| 42 | $renderer = $this->createMock(TemplateRendererInterface::class); |
|
| 43 | $contentCreator = $this->createMock(ContentCreator::class); |
|
| 44 | $parser = $this->createMock(MarkdownDocumentParser::class); |
|
| 45 | $config = [ |
|
| 46 | 'markdown_cms' => ['testconfig'] |
|
| 47 | ]; |
|
| 48 | ||
| 49 | $container->setAllowOverride(true); |
|
| 50 | $container->setService(TemplateRendererInterface::class, $renderer); |
|
| 51 | $container->setService(ContentCreator::class, $contentCreator); |
|
| 52 | $container->setService(MarkdownDocumentParser::class, $parser); |
|
| 53 | $container->setService('config', $config); |
|
| 54 | $container->setAllowOverride(false); |
|
| 55 | ||
| 56 | $action = $this->factory->__invoke($container, SingleBlogEntryAction::class); |
|
| 57 | $this->assertInstanceOf(BlogOverviewAction::class, $action); |
|
| 58 | $this->assertSame($renderer, $action->getTemplateRenderer()); |
|
| 59 | $this->assertSame($contentCreator, $action->getContentCreator()); |
|
| 60 | $this->assertSame($parser, $action->getMarkdownDocumentParser()); |
|
| 61 | $this->assertSame(['testconfig'], $action->getMarkdownCmsConfig()); |
|
| 62 | } |
|
| 63 | } |
|
| @@ 20-61 (lines=42) @@ | ||
| 17 | use Jolicht\MarkdownCms\ContentType\ContentCreator; |
|
| 18 | use Jolicht\MarkdownCms\Markdown\MarkdownDocumentParser; |
|
| 19 | ||
| 20 | class SingleBlogEntryActionFactoryTest extends ServiceManagerAwareTestCase |
|
| 21 | { |
|
| 22 | private $factory; |
|
| 23 | ||
| 24 | protected function setUp() |
|
| 25 | { |
|
| 26 | $this->setConfigProviders([ModuleConfig::class]); |
|
| 27 | parent::setUp(); |
|
| 28 | $this->factory = new SingleBlogEntryActionFactory(); |
|
| 29 | } |
|
| 30 | ||
| 31 | public function testContainerHasService() |
|
| 32 | { |
|
| 33 | $this->assertTrue($this->getContainer()->has(SingleBlogEntryAction::class)); |
|
| 34 | } |
|
| 35 | ||
| 36 | public function testCreateService() |
|
| 37 | { |
|
| 38 | $container = $this->getContainer(); |
|
| 39 | ||
| 40 | $renderer = $this->createMock(TemplateRendererInterface::class); |
|
| 41 | $contentCreator = $this->createMock(ContentCreator::class); |
|
| 42 | $parser = $this->createMock(MarkdownDocumentParser::class); |
|
| 43 | $config = [ |
|
| 44 | 'markdown_cms' => ['testconfig'] |
|
| 45 | ]; |
|
| 46 | ||
| 47 | $container->setAllowOverride(true); |
|
| 48 | $container->setService(TemplateRendererInterface::class, $renderer); |
|
| 49 | $container->setService(ContentCreator::class, $contentCreator); |
|
| 50 | $container->setService(MarkdownDocumentParser::class, $parser); |
|
| 51 | $container->setService('config', $config); |
|
| 52 | $container->setAllowOverride(false); |
|
| 53 | ||
| 54 | $action = $this->factory->__invoke($container, SingleBlogEntryAction::class); |
|
| 55 | $this->assertInstanceOf(SingleBlogEntryAction::class, $action); |
|
| 56 | $this->assertSame($renderer, $action->getTemplateRenderer()); |
|
| 57 | $this->assertSame($contentCreator, $action->getContentCreator()); |
|
| 58 | $this->assertSame($parser, $action->getMarkdownDocumentParser()); |
|
| 59 | $this->assertSame(['testconfig'], $action->getMarkdownCmsConfig()); |
|
| 60 | } |
|
| 61 | } |
|