Пример #1
0
 /**
  * @covers FOF30\Hal\Document::addData
  */
 public function testAddData_fromScratch()
 {
     $data = array('test1' => 'one', 'test2' => 'two', 'testArray' => array('testUno' => 'uno', 'testDue' => 'Due'));
     $document = new Document($data);
     $myLink = new Link('http://www.example.com/link1.json', false, 'test', null, 'A test link');
     $document->addLink('foo', $myLink);
     // Make sure trying to add links with replace=false adds, doesn't replace, links
     $myOtherLink = new Link('http://www.example.com/otherLink.json', false, 'test', null, 'Another test link');
     $document->addLink('foo', $myOtherLink, false);
     $myLinks = array(new Link('http://www.example.com/foo.json', false, 'foobar1'), new Link('http://www.example.com/bar.json', false, 'foobar2'));
     $document->addLinks('foo', $myLinks, false);
     ReflectionHelper::setValue($document, '_data', null);
     $extraData = array('newData' => 'something');
     $document->addData($extraData, true);
     $data = $this->getObjectAttribute($document, '_data');
     $this->assertInternalType('object', $data, 'Line: ' . __LINE__ . '.');
     $this->assertEquals((object) $extraData, $data, 'Line: ' . __LINE__ . '.');
 }