public function test() { $link = new Link(); $link->setHelp('TESThelp'); $link->setTitle('TESTtitle'); $link->setType('TESTtype'); $link->setUrl('TESTurl'); $linkData = ['help' => 'TEST2help', 'title' => 'TEST2title', 'type' => 'TEST2type', 'url' => 'TEST2url']; $this->assertEquals('TESThelp', $link->getHelp()); $this->assertEquals('TESTtitle', $link->getTitle()); $this->assertEquals('TESTtype', $link->getType()); $this->assertEquals('TESTurl', $link->getUrl()); $this->assertJson(json_encode($link)); $link2 = new Link(); $link2->populate($linkData); $this->assertEquals($linkData['url'], $link2->getUrl()); $link2->populate($link); $this->assertEquals($link->getUrl(), $link2->getUrl()); try { $link2->populate('nope'); } catch (\RcmUser\Exception\RcmUserException $e) { $this->assertInstanceOf('\\RcmUser\\Exception\\RcmUserException', $e); return; } $this->fail("Expected exception not thrown"); }
public function test() { $link = new Link(); $link->setHelp('TESThelp'); $link->setTitle('TESTtitle'); $link->setType('TESTtype'); $link->setUrl('TESTurl'); $linksData = [$link]; $links = new Links($linksData); $this->assertEquals($link, $links->getLinks()[0]); $links->addLink($link); $this->assertEquals(2, count($links->getLinks())); $this->assertInstanceOf('\\ArrayIterator', $links->getIterator()); $this->assertJson(json_encode($links)); }