public function testEntityHydratorCanHydrate() { $data = ['name' => 'fooName', 'description' => 'fooDescription', 'url' => 'fooUrl', 'owner' => 'fooOwner', 'module_id' => 999, 'created_at' => '2013-02-28 13:05:00', 'updated_at' => '2014-05-10 06:48:15', 'photo_url' => 'fooPhotoUrl']; $module = new Module(); $module->setCreatedAt('2013-02-28 13:05:00'); $module->setUpdatedAt('2014-05-10 06:48:15'); $module->setDescription('fooDescription'); $module->setId(999); $module->setName('fooName'); $module->setOwner('fooOwner'); $module->setPhotoUrl('fooPhotoUrl'); $module->setUrl('fooUrl'); $hydrator = new ModuleHydrator(); $this->assertEquals($module, $hydrator->hydrate($data, new Module())); }
/** * @param stdClass $repository * @return Entity\Module */ public function register($repository) { $isUpdate = false; $module = $this->moduleMapper->findByUrl($repository->html_url); if ($module) { $isUpdate = true; } else { $module = new Entity\Module(); } $module->setName($repository->name); $module->setDescription($repository->description); $module->setUrl($repository->html_url); $module->setOwner($repository->owner->login); $module->setPhotoUrl($repository->owner->avatar_url); if ($isUpdate) { $this->moduleMapper->update($module); } else { $this->moduleMapper->insert($module); } return $module; }
/** * @return Entity\Module */ private function module() { $module = new Entity\Module(); $module->setName(''); $module->setOwner(''); $module->setDescription(''); $module->setUrl(''); return $module; }
public function testSetUrl() { $url = 'http://example.com'; $this->module->setUrl($url); $this->assertSame($url, $this->module->getUrl()); }