4 * This file is part of Psy Shell.
6 * (c) 2012-2018 Justin Hileman
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Psy\Test\CodeCleaner;
14 use Psy\CodeCleaner\StrictTypesPass;
16 class StrictTypesPassTest extends CodeCleanerTestCase
18 public function setUp()
20 if (version_compare(PHP_VERSION, '7.0', '<')) {
21 $this->markTestSkipped();
24 $this->setPass(new StrictTypesPass());
27 public function testProcess()
29 $this->assertProcessesAs('declare(strict_types=1)', 'declare (strict_types=1);');
30 $this->assertProcessesAs('null', "declare (strict_types=1);\nnull;");
31 $this->assertProcessesAs('declare(strict_types=0)', 'declare (strict_types=0);');
32 $this->assertProcessesAs('null', 'null;');
36 * @dataProvider invalidDeclarations
37 * @expectedException \Psy\Exception\FatalErrorException
39 public function testInvalidDeclarations($code)
41 $this->parseAndTraverse($code);
44 public function invalidDeclarations()
47 ['declare(strict_types=-1)'],
48 ['declare(strict_types=2)'],
49 ['declare(strict_types="foo")'],