Example #1
0
 /**
  * When called will return the array representation
  */
 public function testWhenCalledWillReturnTheArrayRepresentation()
 {
     $typeValue = 'testing';
     $type = new Type($typeValue);
     static::assertInternalType('array', $type->toArray());
     return [$typeValue, $type];
 }
Example #2
0
 /**
  * When called will return the string representation
  */
 public function testWhenCalledWillReturnTheStringRepresentation()
 {
     $typeValue = 'testing';
     $type = new Type($typeValue);
     static::assertInternalType('string', $type->toString());
     static::assertEquals($typeValue, $type->toString());
 }
Example #3
0
 /**
  * When called with options and 'string' will return the string representation in a JSON string
  */
 public function testWhenCalledWithOptionsAndStringWillReturnTheStringRepresentationInAJSONString()
 {
     $typeValue = 'testing';
     $type = new Type($typeValue);
     $options = 0;
     static::assertInternalType('string', $type->toJson($options, 'string'));
     static::assertEquals(json_encode($typeValue, $options), $type->toJson($options, 'string'));
     return [$typeValue, $type, $options];
 }
Example #4
0
 /**
  * When called with a different object with different class will throw an exception
  */
 public function testWhenCalledWithADifferentObjectWithDifferentClassWillThrowAnException()
 {
     $typeValue = 'testing';
     $typeValueTwo = 'notTesting';
     $type = new Type($typeValue);
     $typeTwo = new \stdClass();
     $typeTwo->value = $typeValueTwo;
     try {
         $type->equals($typeTwo);
     } catch (\PHPUnit_Framework_Error $e) {
         static::assertStringStartsWith('Argument 1 passed to Xqddd\\Notifications\\Type::equals() must be an instance of Xqddd\\Notifications\\Type,', $e->getMessage());
         static::assertEquals(4096, $e->getCode());
     }
 }
Example #5
0
 /**
  * When called will return the value stored
  */
 public function testWhenCalledWillReturnTheValueStored()
 {
     $typeValue = 'testing';
     $type = new Type($typeValue);
     static::assertSame($typeValue, $type->getValue());
 }
Example #6
0
 /**
  * @param Type $type
  * @return bool
  */
 public function equals(Type $type)
 {
     return $this->value === $type->getValue();
 }