/** * @dataProvider isAllowedMethodProvider */ public function testIsAllowedMethod($method, $expected) { $id = 1; $name = 'Libcaca'; $ug = new UserGroup(); $ug->setId($id); $ug->setName($name); $this->assertEquals($expected, $ug->isAllowedMethod($method)); }
public function getEndpointNameProvider() { $l = Language::createFromArray(['id' => 1, 'name' => 'French']); $ug = UserGroup::createFromArray(['id' => 1, 'name' => 'UserGroup Test']); $s = Site::createFromArray(['id' => 1, 'name' => 'Example Site', 'userGroupId' => 2, 'url' => 'http://example.com', 'languageId' => 3, 'updatedAt' => '1984-06-01 07:32:23', 'isArchived' => true]); // instance, name, expected return [[$l, null, 'languages'], [$ug, null, 'usergroups'], [$s, null, 'sites'], [$s, 'customname', 'customname']]; }
public function testToJson() { $l = new Language(); $l->setId(123); $l->setName('Language'); $ug = new UserGroup(); $ug->setId(456); $ug->setName('UserGroup'); $id = 1; $dt = new \DateTime(); $w = new Site(); $w->setId($id); $w->setName('Website'); $w->setUserGroup($ug); $w->setUrl('www.example.com'); $w->setLanguage($l); $w->setIsArchived(false); $w->setUpdatedAt($dt); $data = json_decode($w); $lCopy = new Language(); $lCopy->setId($data->languageId); $lCopy->setName('Language'); $ugCopy = new UserGroup(); $ugCopy->setId($data->userGroupId); $ugCopy->setName('UserGroup'); $dtCopy = new \DateTime($data->updatedAt); $wCopy = new Site(); $wCopy->setId($data->id); $wCopy->setName($data->name); $wCopy->setUserGroup($ugCopy); $wCopy->setUrl('www.example.com'); $wCopy->setLanguage($lCopy); $wCopy->setIsArchived($data->isArchived); $wCopy->setUpdatedAt($dtCopy); $this->assertEquals($w, $wCopy, "Websites are different"); }