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 testCreateFromArray() { $data = ['id' => 1, 'name' => 'Libcaca', 'userGroupId' => 234, 'url' => 'www.example.com', 'languageId' => 2, 'isArchived' => true, 'updatedAt' => '1984-06-01T07:34:00']; $sFromArray = Site::createFromArray($data); $sFromObject = Site::createFromArray((object) $data); $this->assertInstanceOf('Core\\Site', $sFromArray); $this->assertInstanceOf('Core\\Site', $sFromObject); $this->assertEquals($sFromArray, $sFromObject, 'Sites are different'); $this->assertEquals(1, $sFromArray->getId()); $this->assertEquals(1, $sFromObject->getId()); }