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