コード例 #1
0
 /**
  * Setting properties and outputting json.
  */
 public function testSetters()
 {
     $obj = new ComponentTestClass();
     $expected = '{"role":"role"}';
     $this->assertJsonStringEqualsJsonString($expected, $obj->json());
     // Test assigning document level objects.
     $expected = '{"role":"role","layout":"key"}';
     $layout = new ComponentLayout();
     $document = new Document('1', 'title', 'en-us', new Layout(2, 512));
     $document->addComponentLayout('key', $layout);
     $obj->setLayout('key', $document);
     $this->assertJsonStringEqualsJsonString($expected, $obj->json());
     @$obj->setLayout('invalid key', $document);
     $this->assertJsonStringEqualsJsonString($expected, $obj->json());
 }