public function test_Published_Post_satisfies_CurrentlyPostSpecification()
 {
     $spec = new CurrentlyPublishedPostSpecification();
     $Post = \Milhojas\Domain\Contents\Post::write(new \Milhojas\Domain\Contents\PostId(1), new \Milhojas\Domain\Contents\PostContent('Title', 'Body'));
     $Post->publish(new \Milhojas\Library\ValueObjects\Dates\DateRange(new \DateTimeImmutable()));
     $this->assertTrue($spec->isSatisfiedBy($Post));
 }
Ejemplo n.º 2
0
 public function test_Post_is_published_on_date()
 {
     $Post = Post::write(new PostId(1), new PostContent('Title', 'Body'));
     $Post->publish(new \Milhojas\Library\ValueObjects\Dates\DateRange(new \DateTimeImmutable('-10 day')));
     $this->assertTrue($Post->isPublished(new \DateTimeImmutable()));
     $this->assertFalse($Post->isPublished(new \DateTimeImmutable('-20 day')));
     $this->assertTrue($Post->isPublished());
 }
Ejemplo n.º 3
0
 public function test_it_handles_post_retired()
 {
     $Post = Post::write(new PostId(1), new PostContent('Title', 'Body'), 'Author');
     $Event = new PostWasRetired(1);
     $Post->apply($Event);
     $this->assertEquals(new PostId(1), $Post->getId());
     $this->assertInstanceOf('\\Milhojas\\Domain\\Contents\\PostStates\\RetiredPostState', $Post->getState());
 }
Ejemplo n.º 4
0
 public function handle(Command $command)
 {
     $Post = Post::write(new PostId($command->getId()), new PostContent($command->getTitle(), $command->getBody()));
     $this->recorder->load($Post->retrieveEvents());
     $this->repository->save($Post);
 }