annotate vendor/psy/psysh/test/Reflection/ReflectionLanguageConstructParameterTest.php @ 19:fa3358dc1485 tip

Add ndrum files
author Chris Cannam
date Wed, 28 Aug 2019 13:14:47 +0100
parents c2387f117808
children
rev   line source
Chris@16 1 <?php
Chris@16 2
Chris@16 3 /*
Chris@16 4 * This file is part of Psy Shell.
Chris@16 5 *
Chris@16 6 * (c) 2012-2018 Justin Hileman
Chris@16 7 *
Chris@16 8 * For the full copyright and license information, please view the LICENSE
Chris@16 9 * file that was distributed with this source code.
Chris@16 10 */
Chris@16 11
Chris@16 12 namespace Psy\Test\Reflection;
Chris@16 13
Chris@16 14 use Psy\Reflection\ReflectionLanguageConstruct;
Chris@16 15 use Psy\Reflection\ReflectionLanguageConstructParameter;
Chris@16 16
Chris@16 17 class ReflectionLanguageConstructParameterTest extends \PHPUnit\Framework\TestCase
Chris@16 18 {
Chris@16 19 public function testOptions()
Chris@16 20 {
Chris@16 21 $keyword = new ReflectionLanguageConstruct('die');
Chris@16 22
Chris@16 23 $refl = new ReflectionLanguageConstructParameter($keyword, 'one', [
Chris@16 24 'isArray' => false,
Chris@16 25 'defaultValue' => null,
Chris@16 26 'isOptional' => false,
Chris@16 27 'isPassedByReference' => false,
Chris@16 28 ]);
Chris@16 29
Chris@16 30 $this->assertNull($refl->getClass());
Chris@16 31 $this->assertEquals('one', $refl->getName());
Chris@16 32 $this->assertFalse($refl->isArray());
Chris@16 33 $this->assertTrue($refl->isDefaultValueAvailable());
Chris@16 34 $this->assertNull($refl->getDefaultValue());
Chris@16 35 $this->assertFalse($refl->isOptional());
Chris@16 36 $this->assertFalse($refl->isPassedByReference());
Chris@16 37
Chris@16 38 $reflTwo = new ReflectionLanguageConstructParameter($keyword, 'two', [
Chris@16 39 'isArray' => true,
Chris@16 40 'isOptional' => true,
Chris@16 41 'isPassedByReference' => true,
Chris@16 42 ]);
Chris@16 43
Chris@16 44 $this->assertNull($refl->getClass());
Chris@16 45 $this->assertEquals('two', $reflTwo->getName());
Chris@16 46 $this->assertTrue($reflTwo->isArray());
Chris@16 47 $this->assertFalse($reflTwo->isDefaultValueAvailable());
Chris@16 48 $this->assertNull($reflTwo->getDefaultValue());
Chris@16 49 $this->assertTrue($reflTwo->isOptional());
Chris@16 50 $this->assertTrue($reflTwo->isPassedByReference());
Chris@16 51
Chris@16 52 $refl = new ReflectionLanguageConstructParameter($keyword, 'three', [
Chris@16 53 'defaultValue' => 3,
Chris@16 54 ]);
Chris@16 55
Chris@16 56 $this->assertNull($refl->getClass());
Chris@16 57 $this->assertEquals('three', $refl->getName());
Chris@16 58 $this->assertFalse($refl->isArray());
Chris@16 59 $this->assertTrue($refl->isDefaultValueAvailable());
Chris@16 60 $this->assertEquals(3, $refl->getDefaultValue());
Chris@16 61 $this->assertFalse($refl->isOptional());
Chris@16 62 $this->assertFalse($refl->isPassedByReference());
Chris@16 63 }
Chris@16 64 }