/** * @test * @group websitesservice */ public function should_update_valid_data() { $id = 1; $data = $this->getKlimtornWebsiteData(); $website = $this->getKlimtorenWebsite(); //TAGS ------------------------------------------ $n_tag_foo = new TagName('foo'); $tag_foo = Tag::register($n_tag_foo); //OBJECTIVES ------------------------------------ $maths = new Course(new Name('wiskunde')); $curr = new Curriculum($maths, 2009); $struc = Structure::register($curr, new Name('structure'), 'chapter'); $n_obj1 = new Name('objective 1'); $obj1 = Objective::register($n_obj1, 'D1', $struc); $n_obj2 = new Name('objective 2'); $obj2 = Objective::register($n_obj2, 'D2', $struc); //MOCKS ----------------------------------------- $this->websitesRepo->shouldReceive('websiteOfId')->with($id)->andReturn($website); $this->tagRepo->shouldReceive('tagOfNameOrCreate')->twice()->andReturn($tag_foo); $this->currRepo->shouldReceive('objectiveOfId')->with(1)->andReturn($obj1); $this->currRepo->shouldReceive('objectiveOfId')->with(2)->andReturn($obj2); $this->websitesRepo->shouldReceive('update'); //SERVICE CALL ------------------------------------ $this->assertEquals('FTP De Klimtoren', $website->name()); $this->assertEquals('http://ftp.klimtoren.be/', $website->url()); $result = $this->websitesService->update($id, $data); $this->assertEquals('VBS De Klimtoren', $website->name()); $this->assertEquals('http://www.klimtoren.be/', $website->url()); $this->assertCount(2, $result->getTags()); $this->assertInstanceOf('Bakgat\\Notos\\Domain\\Model\\Descriptive\\Tag', $result->getTags()[0]); $this->assertCount(2, $result->getObjectives()); $this->assertInstanceOf('Bakgat\\Notos\\Domain\\Model\\Curricula\\Objective', $result->getObjectives()[0]); }