コード例 #1
0
ファイル: WebsiteFixtures.php プロジェクト: bakgat/notos
 public function createWebsites()
 {
     $websites = [['n' => 'Rekenmeeseter', 'u' => 'www.rekenmeester.be', 'o' => ['WIS G1', 'WIS G1.a'], 't' => ['optellen', 'aftrekken']], ['n' => 'Google', 'u' => 'www.google.be', 'o' => ['WIS G7', 'WIS G9', 'WIS G9.e'], 't' => ['optellen', 'Sinterklaas']]];
     foreach ($websites as $awebsite) {
         $website = Website::register(new Name($awebsite['n']), new URL($awebsite['u']));
         foreach ($awebsite['t'] as $atag) {
             $tag = $this->tagRepo->tagOfName(new TagName($atag));
             $website->addTag($tag);
         }
         foreach ($awebsite['o'] as $aobjective) {
             $objective = $this->currRepo->objectiveOfCode($aobjective);
             $website->addObjective($objective);
         }
         $this->manager->persist($website);
         $this->websiteRepo->add($website);
     }
 }
コード例 #2
0
ファイル: WebsitesService.php プロジェクト: bakgat/notos
 /**
  * Updates a website (with tags and objectives) of a given id .
  * @param $id
  * @param $data
  * @return Website
  * @throws WebsiteNotFoundException
  */
 public function update($id, $data)
 {
     //MANDATORY FIELDS ---------------------------------
     $this->nameIsRequired($data);
     $this->urlIsRequired($data);
     /** @var Website $website */
     $website = $this->websiteOfId($id);
     if (!$website) {
         throw new WebsiteNotFoundException($id);
     }
     $website->setName(new Name($data['name']));
     $website->setUrl(new URL($data['url']));
     $this->setDescription($data, $website);
     $this->addImage($data, $website);
     $this->syncTags($data, $website);
     $this->syncObjectives($data, $website);
     $this->websitesRepository->update($website);
     return $website;
 }
コード例 #3
0
 /**
  * @test
  * @group websitesrepo
  */
 public function should_return_null_when_website_not_found_with_url()
 {
     $url = new URL('foo.be');
     $site = $this->websiteRepo->websiteOfURL($url);
     $this->assertNull($site);
 }