comparison vendor/psy/psysh/test/Reflection/ReflectionLanguageConstructTest.php @ 16:c2387f117808

Routine composer update
author Chris Cannam
date Tue, 10 Jul 2018 15:07:59 +0100
parents
children
comparison
equal deleted inserted replaced
15:e200cb7efeb3 16:c2387f117808
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\Reflection;
13
14 use Psy\Reflection\ReflectionLanguageConstruct;
15
16 class ReflectionLanguageConstructTest extends \PHPUnit\Framework\TestCase
17 {
18 /**
19 * @dataProvider languageConstructs
20 */
21 public function testConstruction($keyword)
22 {
23 $refl = new ReflectionLanguageConstruct($keyword);
24 $this->assertEquals($keyword, $refl->getName());
25 $this->assertEquals($keyword, (string) $refl);
26 }
27
28 /**
29 * @dataProvider languageConstructs
30 */
31 public function testKnownLanguageConstructs($keyword)
32 {
33 $this->assertTrue(ReflectionLanguageConstruct::isLanguageConstruct($keyword));
34 }
35
36 /**
37 * @dataProvider languageConstructs
38 */
39 public function testFileName($keyword)
40 {
41 $refl = new ReflectionLanguageConstruct($keyword);
42 $this->assertFalse($refl->getFileName());
43 }
44
45 /**
46 * @dataProvider languageConstructs
47 */
48 public function testReturnsReference($keyword)
49 {
50 $refl = new ReflectionLanguageConstruct($keyword);
51 $this->assertFalse($refl->returnsReference());
52 }
53
54 /**
55 * @dataProvider languageConstructs
56 */
57 public function testGetParameters($keyword)
58 {
59 $refl = new ReflectionLanguageConstruct($keyword);
60 $this->assertNotEmpty($refl->getParameters());
61 }
62
63 /**
64 * @dataProvider languageConstructs
65 * @expectedException \RuntimeException
66 */
67 public function testExportThrows($keyword)
68 {
69 ReflectionLanguageConstruct::export($keyword);
70 }
71
72 public function languageConstructs()
73 {
74 return [
75 ['isset'],
76 ['unset'],
77 ['empty'],
78 ['echo'],
79 ['print'],
80 ['die'],
81 ['exit'],
82 ];
83 }
84
85 /**
86 * @dataProvider unknownLanguageConstructs
87 * @expectedException \InvalidArgumentException
88 */
89 public function testUnknownLanguageConstructsThrowExceptions($keyword)
90 {
91 new ReflectionLanguageConstruct($keyword);
92 }
93
94 public function unknownLanguageConstructs()
95 {
96 return [
97 ['async'],
98 ['await'],
99 ['comefrom'],
100 ];
101 }
102 }