Updated from some -dev modules to alpha, beta or full releases
[yaffs-website] / vendor / psy / psysh / test / CodeCleaner / StrictTypesPassTest.php
1 <?php
2
3 /*
4  * This file is part of Psy Shell.
5  *
6  * (c) 2012-2018 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($code)
40     {
41         $this->parseAndTraverse($code);
42     }
43
44     public function invalidDeclarations()
45     {
46         return [
47             ['declare(strict_types=-1)'],
48             ['declare(strict_types=2)'],
49             ['declare(strict_types="foo")'],
50         ];
51     }
52 }