/** @test */
 public function a_draft_can_be_deleted()
 {
     $id = PostId::generate();
     $this->givenANewPost($id)->when(function ($post) {
         $post->delete();
     })->then([new DraftDeleted($id)]);
 }
 /** @test */
 function it_changes_the_contents_of_a_post()
 {
     // Currently hardcoding published at and member id
     $id = PostId::generate();
     $member = new MemberId('6703202d-6556-404d-988c-b76c5a34b97c');
     $this->scenario->given([new PostWritten($id, 'My Title', 'My Content', 'blog')])->when(new PostTitleChanged($id, 'New Title'))->then([new PostList($id, $member, 'New Title', 'My Content', 'blog', new DateTimeImmutable('2016-09-02T10:14:05'))])->when(new PostContentChanged($id, 'New Content'))->then([new PostList($id, $member, 'New Title', 'New Content', 'blog', new DateTimeImmutable('2016-09-02T10:14:05'))]);
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     for ($i = 0; $i < 50; $i++) {
         DB::table('posts')->insert(['id' => PostId::generate(), 'title' => str_random(20), 'content' => str_random(100)]);
     }
     $this->call(CommitteesSeeder::class);
     $this->call(PostsSeeder::class);
     $this->call(RegistrationRequestsSeeder::class);
     $this->call(BooksSeeder::class);
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $repo = App::make(PostRepository::class);
     $faker = App::make(Faker\Generator::class);
     $faker->addProvider(new \DavidBadura\FakerMarkdownGenerator\FakerProvider($faker));
     $categories = [PostCategory::fromString(PostCategory::BLOGPOST), PostCategory::fromString(PostCategory::NEWSPOST)];
     for ($i = 0; $i < 10; $i++) {
         $id = PostId::generate();
         $post = Post::createDraft($id, $faker->sentence, implode($faker->paragraphs(4), "\n"), $faker->randomElement($categories));
         $post->setPublishDate(new Carbon\Carbon());
         $repo->save($post);
     }
 }
 public function store(Request $req, PostRepository $repo)
 {
     //Validate doesn't work?
     // $this->validate($req, [
     //     'title' => 'required|max:255',
     //     'content' => 'required',
     //     'type' => 'in:blog,news',
     //     'publishes_at' => 'date',
     // ]);
     $id = PostId::generate();
     $post = Post::createDraft($id, $req->input('title'), $req->input('content'), PostCategory::fromString($req->input('type')));
     $post->setPublishDate(\Carbon\Carbon::now());
     /// @todo
     $repo->save($post);
     return redirect('/admin/post');
 }
 protected function createInstance()
 {
     return new PostList(PostId::generate(), MemberId::generate(), 'My Title', 'My Content', 'blog', new DateTimeImmutable('2016-09-02T10:14:05'));
 }