public function getEndpointNameProvider()
 {
     $l = EntityFactory::createFromArray('Language', ['id' => 1, 'name' => 'French']);
     $ug = EntityFactory::createFromArray('UserGroup', ['id' => 1, 'name' => 'UserGroup Test']);
     $s = EntityFactory::createFromArray('Site', ['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'];
     $ugFromArray = EntityFactory::createFromArray('UserGroup', $data);
     $ugFromObject = EntityFactory::createFromArray('UserGroup', $data);
     $this->assertInstanceOf('SmartAdServer\\Core\\UserGroup', $ugFromArray);
     $this->assertInstanceOf('SmartAdServer\\Core\\UserGroup', $ugFromObject);
     $this->assertEquals($ugFromArray, $ugFromObject, 'UserGroups are different');
     $this->assertEquals(1, $ugFromArray->getId());
     $this->assertEquals(1, $ugFromObject->getId());
 }
 public function testCreateFromArray()
 {
     $data = ['id' => 1, 'name' => 'Libcaca', 'isArchived' => true];
     $fFromArray = EntityFactory::createFromArray('Format', $data);
     $fFromObject = EntityFactory::createFromArray('Format', (object) $data);
     $this->assertInstanceOf('SmartAdServer\\Core\\Format', $fFromArray);
     $this->assertInstanceOf('SmartAdServer\\Core\\Format', $fFromObject);
     $this->assertEquals($fFromArray, $fFromObject, 'Formats are different');
     $this->assertEquals(1, $fFromArray->getId());
     $this->assertEquals(1, $fFromObject->getId());
 }
Example #4
0
 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 = EntityFactory::createFromArray('Site', $data);
     $sFromObject = EntityFactory::createFromArray('Site', $data);
     $this->assertInstanceOf('SmartAdServer\\Core\\Site', $sFromArray);
     $this->assertInstanceOf('SmartAdServer\\Core\\Site', $sFromObject);
     $this->assertEquals($sFromArray, $sFromObject, 'Sites are different');
     $this->assertEquals(1, $sFromArray->getId());
     $this->assertEquals(1, $sFromObject->getId());
 }
 public function testCreateFromArray()
 {
     $data = ['id' => 1, 'name' => 'Libcaca', 'siteId' => 234, 'formatIds' => [1, 2, 3], 'isArchived' => true];
     $pgFromArray = EntityFactory::createFromArray('PageGroup', $data);
     $pgFromObject = EntityFactory::createFromArray('PageGroup', (object) $data);
     $this->assertInstanceOf('SmartAdServer\\Core\\PageGroup', $pgFromArray);
     $this->assertInstanceOf('SmartAdServer\\Core\\PageGroup', $pgFromObject);
     $this->assertInstanceOf('SmartAdServer\\Core\\Site', $pgFromArray->getSite());
     $this->assertInstanceOf('SmartAdServer\\Core\\Site', $pgFromObject->getSite());
     $this->assertEquals($pgFromArray, $pgFromObject, 'PageGroups are different');
     $this->assertEquals(1, $pgFromArray->getId());
     $this->assertEquals(1, $pgFromObject->getId());
 }
Example #6
0
 public function testCreateFromArray()
 {
     $data = ['id' => 1, 'name' => 'Libcaca', 'fullName' => 'LibcacaFull', 'pageGroupId' => 234, 'parentPageId' => 789, 'isArchived' => true, 'updatedAt' => '1984-06-01T07:34:00'];
     $pFromArray = EntityFactory::createFromArray('Page', $data);
     $pFromObject = EntityFactory::createFromArray('Page', $data);
     $this->assertInstanceOf('SmartAdServer\\Core\\Page', $pFromArray);
     $this->assertInstanceOf('SmartAdServer\\Core\\Page', $pFromObject);
     $this->assertEquals($pFromArray, $pFromObject, 'Pages are different');
     $this->assertEquals(1, $pFromArray->getId());
     $this->assertEquals(1, $pFromObject->getId());
 }