Yaffs site version 1.1
[yaffs-website] / vendor / psy / psysh / test / Psy / Test / CodeCleaner / StrictTypesPassTest.php
1 <?php
2
3 /*
4  * This file is part of Psy Shell.
5  *
6  * (c) 2012-2017 Justin Hileman
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11
12 namespace Psy\Test\CodeCleaner;
13
14 use Psy\CodeCleaner\StrictTypesPass;
15
16 class StrictTypesPassTest extends CodeCleanerTestCase
17 {
18     public function setUp()
19     {
20         if (version_compare(PHP_VERSION, '7.0', '<')) {
21             $this->markTestSkipped();
22         }
23
24         $this->setPass(new StrictTypesPass());
25     }
26
27     public function testProcess()
28     {
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;');
33     }
34
35     /**
36      * @dataProvider invalidDeclarations
37      * @expectedException \Psy\Exception\FatalErrorException
38      */
39     public function testInvalidDeclarations($declaration)
40     {
41         $stmts = $this->parse($declaration);
42         $this->traverser->traverse($stmts);
43     }
44
45     public function invalidDeclarations()
46     {
47         return array(
48             array('declare(strict_types=-1)'),
49             array('declare(strict_types=2)'),
50             array('declare(strict_types="foo")'),
51         );
52     }
53 }