public function testOffsetGetGetsProperties() { $res = new Response(); $res->setProperties(array('foo' => 'bar', 'bar' => 'baz')); $this->assertEquals('bar', $res['foo']); $this->assertEquals('baz', $res['bar']); }
public function testAddItemNestedResponse() { $res = new Response(); $res->setProperties(array('foo' => 'bar'))->addLink('self', '/test'); $res2 = clone $res; $res2->addItem('item', $res); $expected = array('properties' => array('foo' => 'bar'), 'links' => array(array('rel' => array('self'), 'href' => '/test'))); $expected['entities'][] = $expected; $format = new Formatter\Siren($res2); $this->assertEquals($expected, $format->toArray()); }
public function testAddItemNestedResponse() { $res = new Response(); $res->setProperties(array('foo' => 'bar'))->addLink('self', '/test'); $res2 = clone $res; $res2->addItem('item', $res); $expected = array('_links' => array('self' => array('href' => '/test')), 'foo' => 'bar'); $expected['_embedded']['item'] = $expected; $format = new Formatter\Hal($res2); $this->assertEquals($expected, $format->toArray()); }