Security update for Core, with self-updated composer
[yaffs-website] / vendor / psy / psysh / test / Psy / Test / CodeCleaner / FunctionContextPassTest.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 PhpParser\NodeTraverser;
15 use Psy\CodeCleaner\FunctionContextPass;
16
17 class FunctionContextPassTest extends CodeCleanerTestCase
18 {
19     public function setUp()
20     {
21         $this->pass      = new FunctionContextPass();
22         $this->traverser = new NodeTraverser();
23         $this->traverser->addVisitor($this->pass);
24     }
25
26     /**
27      * @dataProvider validStatements
28      */
29     public function testProcessStatementPasses($code)
30     {
31         $stmts = $this->parse($code);
32         $this->traverser->traverse($stmts);
33
34         // @todo a better thing to assert here?
35         $this->assertTrue(true);
36     }
37
38     public function validStatements()
39     {
40         return array(
41             array('function foo() { yield; }'),
42             array('if (function(){ yield; })'),
43         );
44     }
45
46     /**
47      * @dataProvider invalidYieldStatements
48      * @expectedException \Psy\Exception\FatalErrorException
49      */
50     public function testInvalidYield($code)
51     {
52         if (version_compare(PHP_VERSION, '5.4', '<')) {
53             $this->markTestSkipped();
54         }
55
56         $stmts = $this->parse($code);
57         $this->traverser->traverse($stmts);
58     }
59
60     public function invalidYieldStatements()
61     {
62         return array(
63             array('yield'),
64             array('if (yield)'),
65         );
66     }
67 }