4 * This file is part of Psy Shell.
6 * (c) 2012-2017 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($declaration)
41 $stmts = $this->parse($declaration);
42 $this->traverser->traverse($stmts);
45 public function invalidDeclarations()
48 array('declare(strict_types=-1)'),
49 array('declare(strict_types=2)'),
50 array('declare(strict_types="foo")'),