More updates to stop using dev or alpha or beta versions.
[yaffs-website] / vendor / psy / psysh / test / CodeCleaner / ExitPassTest.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\ExitPass;
15
16 class ExitPassTest extends CodeCleanerTestCase
17 {
18     /**
19      * @var string
20      */
21     private $expectedExceptionString = '\\Psy\\Exception\\BreakException::exitShell()';
22
23     public function setUp()
24     {
25         $this->setPass(new ExitPass());
26     }
27
28     /**
29      * @dataProvider dataProviderExitStatement
30      */
31     public function testExitStatement($from, $to)
32     {
33         $this->assertProcessesAs($from, $to);
34     }
35
36     /**
37      * Data provider for testExitStatement.
38      *
39      * @return array
40      */
41     public function dataProviderExitStatement()
42     {
43         return [
44             ['exit;', "{$this->expectedExceptionString};"],
45             ['exit();', "{$this->expectedExceptionString};"],
46             ['die;', "{$this->expectedExceptionString};"],
47             ['exit(die(die));', "{$this->expectedExceptionString};"],
48             ['if (true) { exit; }', "if (true) {\n    {$this->expectedExceptionString};\n}"],
49             ['if (false) { exit; }', "if (false) {\n    {$this->expectedExceptionString};\n}"],
50             ['1 and exit();', "1 and {$this->expectedExceptionString};"],
51             ['foo() or die', "foo() or {$this->expectedExceptionString};"],
52             ['exit and 1;', "{$this->expectedExceptionString} and 1;"],
53             ['if (exit) { echo $wat; }', "if ({$this->expectedExceptionString}) {\n    echo \$wat;\n}"],
54             ['exit or die;', "{$this->expectedExceptionString} or {$this->expectedExceptionString};"],
55             ['switch (die) { }', "switch ({$this->expectedExceptionString}) {\n}"],
56             ['for ($i = 1; $i < 10; die) {}', "for (\$i = 1; \$i < 10; {$this->expectedExceptionString}) {\n}"],
57         ];
58     }
59 }