Exemplo n.º 1
0
 function it_may_allow_a_type(Type $type, Type $anotherType)
 {
     $type->allows($anotherType)->willReturn(true);
     $this->allows($anotherType)->shouldBe(true);
     $type->allows($anotherType)->willReturn(false);
     $this->allows($anotherType)->shouldBe(false);
 }
Exemplo n.º 2
0
 function it_might_allow_types_to_be_passed(Type $type, Type $anotherType)
 {
     $type->allows($anotherType)->willReturn(false);
     $this->allows($anotherType)->shouldBe(false);
     $type->allows($anotherType)->willReturn(true);
     $this->allows($anotherType)->shouldBe(true);
 }
Exemplo n.º 3
0
 function it_does_not_allow_collections_of_other_generics(ClassType $collection, Type $generic)
 {
     $allowedCollectionClass = new ClassType(ClassReflectionStubBuilder::build()->implement(Traversable::class)->finish());
     $notAllowedGeneric = new StringType();
     $collection->allows($allowedCollectionClass)->willReturn(true);
     $generic->allows($notAllowedGeneric)->willReturn(false);
     $this->allows(new CollectionType($allowedCollectionClass, $notAllowedGeneric))->shouldBe(false);
 }
Exemplo n.º 4
0
 public function allows(Type $type) : bool
 {
     return $this->type->allows($type);
 }
Exemplo n.º 5
0
 function it_allows_composed_types_if_all_types_are_allowed(Type $decorated)
 {
     $decorated->allows(Argument::type(StringType::class))->willReturn(false);
     $this->allows(new ComposedType(new NullType(), new NullType()))->shouldBe(true);
     $this->allows(new ComposedType(new NullType(), new StringType()))->shouldBe(false);
 }