/** * Test for __toString method */ public function testToString() { // Change value and assert new $newCode = 'code'; $expectedCode = '[' . $newCode . ']'; $this->category->setCode($newCode); $this->assertEquals($expectedCode, $this->category->__toString()); $newLabel = 'test-label'; $this->assertEntity($this->category->setLocale('en_US')); $this->assertEntity($this->category->setLabel($newLabel)); $this->assertEquals($newLabel, $this->category->__toString()); // if no translation, assert the expected code is returned $this->category->setLocale('fr_FR'); $this->assertEquals($expectedCode, $this->category->__toString()); // if empty translation, assert the expected code is returned $this->category->setLabel(''); $this->assertEquals($expectedCode, $this->category->__toString()); }
/** * {@inheritDoc} */ public function __toString() { $this->__initializer__ && $this->__initializer__->__invoke($this, '__toString', array()); return parent::__toString(); }