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)); }
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()); }
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()); }
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); }