1 | <?php |
||
17 | class ParseContentExecutorTest extends TestCase |
||
18 | { |
||
19 | private $executor, $contentParser; |
||
20 | |||
21 | protected function setUp() |
||
22 | { |
||
23 | $this->contentParser = $this->getMockBuilder(ContentParser::class) |
||
24 | ->setMethods(['__invoke']) |
||
25 | ->disableOriginalConstructor() |
||
26 | ->getMock(); |
||
27 | $this->executor = new ParseContentExecutor($this->contentParser); |
||
28 | } |
||
29 | |||
30 | public function testGetContentParser() |
||
31 | { |
||
32 | $this->assertSame($this->contentParser, $this->executor->getContentParser()); |
||
33 | } |
||
34 | |||
35 | public function testGetObservers() |
||
36 | { |
||
37 | $this->assertSame([], $this->executor->getObservers()); |
||
38 | } |
||
39 | |||
40 | public function testAddObserver() |
||
41 | { |
||
42 | $observer = $this->getMockBuilder(ParsedContentObserverInterface::class)->getMock(); |
||
43 | $this->executor->addObserver($observer); |
||
44 | $this->assertSame([$observer], $this->executor->getObservers()); |
||
45 | } |
||
46 | |||
47 | public function testNotifyObservers() |
||
48 | { |
||
49 | $observer = $this->getMockBuilder(ParsedContentObserverInterface::class) |
||
50 | ->setMethods(['__invoke']) |
||
51 | ->getMock(); |
||
52 | |||
53 | $config = ['testConfig']; |
||
54 | |||
55 | $this->contentParser->expects($this->once()) |
||
56 | ->method('__invoke') |
||
57 | ->will($this->returnValue($config)); |
||
58 | |||
59 | $observer->expects(($this->once())) |
||
60 | ->method('__invoke') |
||
61 | ->with($this->equalTo($config)); |
||
62 | |||
63 | $this->executor->addObserver($observer); |
||
64 | $this->executor->__invoke(); |
||
65 | } |
||
66 | } |