Example #1
0
 public function testGetFormByRel()
 {
     $form = array('method' => 'get', 'href' => 'http://placekitten.com/200/300');
     $res = new Response();
     $res->addForm('kitten', $form);
     $formResult = $res->getForm('kitten');
     $this->assertEquals($form, $formResult);
 }
Example #2
0
 public function testOffsetUnsetRemovesProperties()
 {
     $res = new Response();
     $res['foo'] = 'bar';
     $res['bar'] = 'baz';
     $props = $res->getProperties();
     $this->assertEquals(true, isset($props['foo']));
     unset($props['foo']);
     $this->assertEquals(false, isset($props['foo']));
 }
Example #3
0
 public function testSetItemsIsCollection()
 {
     $res = new Response();
     $res->setItems('items', array(array('some' => 'value', 'something' => 'else', 'another' => 'one'), array('some' => 'value2', 'something' => 'else2', 'another' => 'two')));
     $expected = array('entities' => array(array('properties' => array('some' => 'value', 'something' => 'else', 'another' => 'one')), array('properties' => array('some' => 'value2', 'something' => 'else2', 'another' => 'two'))));
     $format = new Formatter\Siren($res);
     $this->assertEquals($expected, $format->toArray());
 }
Example #4
0
 public function testSetItemsIsCollection()
 {
     $res = new Response();
     $res->setItems('items', array(array('some' => 'value', 'something' => 'else', 'another' => 'one'), array('some' => 'value2', 'something' => 'else2', 'another' => 'two')));
     $res->setItems('users', array(array('name' => 'Chester Tester', 'username' => 'test')));
     $expected = array('_embedded' => array('items' => array(array('some' => 'value', 'something' => 'else', 'another' => 'one'), array('some' => 'value2', 'something' => 'else2', 'another' => 'two')), 'users' => array(array('name' => 'Chester Tester', 'username' => 'test'))));
     $format = new Formatter\Hal($res);
     $this->assertEquals($expected, $format->toArray());
 }