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