public function __construct()
 {
     $this->postParser = new PostParser();
     $this->tags = Tag::all();
     $this->dificultyLevels = PostDificulty::all();
     $this->posts = Post::all();
 }
 /**
  * Test Dificulty Level -> post releationship
  *
  * @return void
  */
 public function testDificultyLevelPostRelationship()
 {
     $this->assertTrue(PostDificulty::findOrFail(1) instanceof PostDificulty);
     $relationshipCollection = PostDificulty::find(1)->posts()->get();
     $collection = collect([]);
     $this->assertTrue($relationshipCollection instanceof $collection);
 }
 /**
  * Assert that the numbers of posts doens't decline after running update command
  *
  * @return void
  */
 public function testNumberOfPostsIsEqualOrHigherAfterUpdate()
 {
     $totalPosts = Post::count();
     $totalDificultyLevels = PostDificulty::count();
     Artisan::call('update', ['--migrationRefresh' => 'default']);
     $this->assertTrue($totalDificultyLevels <= PostDificulty::count());
     $this->assertTrue($totalPosts <= Post::count());
 }
 public function run()
 {
     DB::table('post_dificulties')->delete();
     PostDificulty::create(['title' => 'Very easy', 'description' => 'Some minutes of reading are enough', 'level' => 1]);
     PostDificulty::create(['title' => 'Easy', 'description' => 'Some minutes of reading and thinking about it are enough', 'level' => 2]);
     PostDificulty::create(['title' => 'Medium', 'description' => 'Some exercising and paper to get a full understandment of it', 'level' => 3]);
     PostDificulty::create(['title' => 'Hard', 'description' => 'A lot of exercising and paper to get a full understandment of it', 'level' => 4]);
     PostDificulty::create(['title' => 'Very hard', 'description' => 'It will take you some weeks or even months to fully understand, use and explain it easily', 'level' => 5]);
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($level)
 {
     $tag = PostDificulty::where('level', $level)->firstOrFail();
     $posts = Post::with('tags')->where('post_dificulty_id', '=', $level)->orderBy('created_at', 'desc')->paginate(15);
     return view('post-dificulty.show', compact('tag', 'posts'));
 }
 /**
  * Asserting /dificulty-level/1 is accessible and the title is visible
  *
  * @return void
  */
 public function testDificultyLevelTitleIsVisible()
 {
     $this->visit('/dificulty-level/1')->see(strtolower(PostDificulty::find(1)->title))->seeStatusCode(200);
 }