1<?php
2/*
3 * This file is part of php-token-stream.
4 *
5 * (c) Sebastian Bergmann <sebastian@phpunit.de>
6 *
7 * For the full copyright and license information, please view the LICENSE
8 * file that was distributed with this source code.
9 */
10
11use PHPUnit\Framework\TestCase;
12
13class PHP_Token_IncludeTest extends TestCase
14{
15    /**
16     * @var PHP_Token_Stream
17     */
18    private $ts;
19
20    protected function setUp()
21    {
22        $this->ts = new PHP_Token_Stream(TEST_FILES_PATH . 'source3.php');
23    }
24
25    /**
26     * @covers PHP_Token_Includes::getName
27     * @covers PHP_Token_Includes::getType
28     */
29    public function testGetIncludes()
30    {
31        $this->assertSame(
32          ['test4.php', 'test3.php', 'test2.php', 'test1.php'],
33          $this->ts->getIncludes()
34        );
35    }
36
37    /**
38     * @covers PHP_Token_Includes::getName
39     * @covers PHP_Token_Includes::getType
40     */
41    public function testGetIncludesCategorized()
42    {
43        $this->assertSame(
44          [
45            'require_once' => ['test4.php'],
46            'require'      => ['test3.php'],
47            'include_once' => ['test2.php'],
48            'include'      => ['test1.php']
49          ],
50          $this->ts->getIncludes(true)
51        );
52    }
53
54    /**
55     * @covers PHP_Token_Includes::getName
56     * @covers PHP_Token_Includes::getType
57     */
58    public function testGetIncludesCategory()
59    {
60        $this->assertSame(
61          ['test4.php'],
62          $this->ts->getIncludes(true, 'require_once')
63        );
64    }
65}
66