Completed
Push — develop ( 8eb671...133594 )
by Mike
19:30 queued 09:24
created

RestructuredText/Visitors/DiscoverTest.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
/**
3
 * phpDocumentor
4
 *
5
 * PHP Version 5.3
6
 *
7
 * @copyright 2010-2018 Mike van Riel / Naenius (http://www.naenius.com)
8
 * @license   http://www.opensource.org/licenses/mit-license.php MIT
9
 * @link      http://phpdoc.org
10
 */
11
12
namespace phpDocumentor\Plugin\Scrybe\Converter\RestructuredText\Visitors;
13
14
use Mockery as m;
15
use phpDocumentor\Plugin\Scrybe\Converter\Metadata\TableOfContents;
16
17
/**
18
 * Test class for the Discovery Visitor.
19
 */
20
class DiscoverTest extends \Mockery\Adapter\Phpunit\MockeryTestCase
21
{
22
    const FILENAME = 'test';
23
24
    protected $document = null;
25
26
    protected $converter = null;
27
28
    protected $table_of_contents = null;
29
30
    /**
31
     * @var Discover
32
     */
33
    protected $object;
34
35
    /**
36
     * Sets up the fixture, for example, opens a network connection.
37
     * This method is called before a test is executed.
38
     */
39
    protected function setUp()
40
    {
41
        $this->object = new Discover($this->getDocumentMock(), '');
42
    }
43
44
    protected function getDocumentMock()
45
    {
46
        if (!$this->document) {
47
            $file = m::mock('\phpDocumentor\Fileset\File');
48
            $file->shouldReceive('getFileName')
49
                ->andReturn(self::FILENAME);
50
51
            $this->document = m::mock('\phpDocumentor\Plugin\Scrybe\Converter\RestructuredText\Document');
52
            $this->document->shouldDeferMissing();
0 ignored issues
show
Deprecated Code introduced by
The method Mockery\MockInterface::shouldDeferMissing() has been deprecated with message: 2.0.0 Please use makePartial() instead

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
53
            $this->document->shouldReceive('getConverter')
54
                ->andReturn($this->getConverterMock());
55
56
            $this->document->shouldReceive('getFile')
57
                ->andReturn($file);
58
        }
59
60
        return $this->document;
61
    }
62
63
    protected function getConverterMock()
64
    {
65
        if (!$this->converter) {
66
            $this->converter = m::mock('\phpDocumentor\Plugin\Scrybe\Converter\RestructuredText\ToHtml');
67
            $this->converter->shouldReceive('getTableOfContents')
68
                ->andReturn($this->getTableOfContents());
69
        }
70
71
        return $this->converter;
72
    }
73
74
    protected function getTableOfContents()
75
    {
76
        if (!$this->table_of_contents) {
77
            $this->table_of_contents = new TableOfContents();
78
        }
79
80
        return $this->table_of_contents;
81
    }
82
83
    public function testRetrieveTableOfContents()
84
    {
85
        $this->assertSame(
86
            $this->getTableOfContents(),
87
            $this->object->getTableOfContents()
88
        );
89
    }
90
91
    public function testRetrieveDocument()
92
    {
93
        $this->assertSame(
94
            $this->getDocumentMock(),
95
            $this->object->getDocument()
96
        );
97
    }
98
}
99