isAbstractType() 공개 정적인 메소드

public static isAbstractType ( AbstractType | mixed $type ) : boolean
$type AbstractType | mixed
리턴 boolean
예제 #1
0
 public function testScalarPrimitives()
 {
     foreach (TypeFactory::getScalarTypesNames() as $typeName) {
         $scalarType = TypeFactory::getScalarType($typeName);
         $testDataMethod = 'get' . $typeName . 'TestData';
         $this->assertNotEmpty($scalarType->getDescription());
         $this->assertEquals($scalarType->getKind(), TypeMap::KIND_SCALAR);
         $this->assertEquals($scalarType->isCompositeType(), false);
         $this->assertEquals(TypeService::isAbstractType($scalarType), false);
         $this->assertEquals($scalarType->getType(), $scalarType);
         $this->assertEquals($scalarType->getType(), $scalarType->getNamedType());
         $this->assertNull($scalarType->getConfig());
         foreach (call_user_func(['Youshido\\Tests\\DataProvider\\TestScalarDataProvider', $testDataMethod]) as list($data, $serialized, $isValid)) {
             $this->assertSerialization($scalarType, $data, $serialized);
             $this->assertParse($scalarType, $data, $serialized);
             if ($isValid) {
                 $this->assertTrue($scalarType->isValidValue($data), $typeName . ' validation for :' . serialize($data));
             } else {
                 $this->assertFalse($scalarType->isValidValue($data), $typeName . ' validation for :' . serialize($data));
             }
         }
     }
     try {
         TypeFactory::getScalarType('invalid type');
     } catch (\Exception $e) {
         $this->assertEquals('Configuration problem with type invalid type', $e->getMessage());
     }
     $this->assertEquals('String', (string) new StringType());
 }
예제 #2
0
 public function testNonNullType()
 {
     $stringType = new StringType();
     $nonNullType = new NonNullType(new StringType());
     $nonNullOnString = new NonNullType(TypeMap::TYPE_STRING);
     $testArray = ['a' => 'b'];
     $this->assertEquals($nonNullType->getName(), null, 'Empty non-null name');
     $this->assertEquals($nonNullType->getKind(), TypeMap::KIND_NON_NULL);
     $this->assertEquals($nonNullType->getType(), new NonNullType($stringType));
     $this->assertEquals($nonNullType->getNullableType(), $stringType);
     $this->assertEquals($nonNullType->getNullableType(), $nonNullOnString->getNullableType());
     $this->assertEquals($nonNullType->getNamedType(), $stringType);
     $this->assertEquals($nonNullType->getTypeOf(), $stringType);
     $this->assertEquals($nonNullType->isCompositeType(), true);
     $this->assertEquals(TypeService::isAbstractType($nonNullType), false);
     $this->assertFalse($nonNullType->isValidValue(null));
     $this->assertTrue($nonNullType->isValidValue($stringType));
     $this->assertFalse($nonNullType->isValidValue(new \stdClass()));
     $this->assertEquals($nonNullType->parseValue($testArray), '');
     $this->assertEquals($nonNullType->resolve($testArray), $testArray);
 }
예제 #3
0
 public function testIsAbstractType()
 {
     $this->assertTrue(TypeService::isAbstractType(new TestInterfaceType()));
     $this->assertFalse(TypeService::isAbstractType(new StringType()));
     $this->assertFalse(TypeService::isAbstractType('invalid type'));
 }