Example #1
0
 /** @test */
 public function it_creates_a_post()
 {
     $user = factory(User::class)->create();
     $user->assignRole(Role::author());
     $post = factory(Post::class)->make();
     $this->actingAs($user)->visit(route('management.posts.create'))->type($post->title, 'title')->type($post->summary, 'summary')->type($post->header_background, 'header_background')->select($post->category->id, 'category_id')->type($post->content, 'content')->press('Create')->see('Post created.');
 }
Example #2
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $authors = factory(App\Gazette\Models\User::class, 3)->create(['role_id' => Role::author()->id]);
     $posts = factory(App\Gazette\Models\Post::class, 13)->create();
     foreach ($posts as $post) {
         $post->assignAuthor($authors->random());
     }
 }
Example #3
0
 /** @test */
 public function it_reads_contacts_index()
 {
     $contactRequest = factory(\App\Gazette\Models\ContactRequest::class)->create();
     $user = factory(\App\Gazette\Models\User::class)->create();
     $user->assignRole(Role::administrator());
     # Access through sidebar
     $this->actingAs($user)->visit(route('management.home'))->click('contact-requests-index')->seePageIs(route('management.contact-requests.index'))->see('All Contact Requests')->see('Name')->see($contactRequest->name)->see('Email')->see($contactRequest->email)->see('Phone Number')->see($contactRequest->phone_number)->see('Peek')->see(substr($contactRequest->message, 0, 23))->see('Viewed')->see('<i class="fa fa-eye-slash"></i>')->see('Actions')->see(link_to_route('management.contact-requests.show', 'Show', $contactRequest, ["class" => "btn btn-primary"]))->see('<form method="POST" action="' . route("management.contact-requests.destroy", $contactRequest) . '" accept-charset="UTF-8"><input name="_method" type="hidden" value="DELETE">');
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::create('roles', function (Blueprint $table) {
         $table->increments('id');
         $table->string('name')->unique();
         $table->timestamps();
     });
     Role::create(['name' => Role::ADMINISTRATOR]);
     Role::create(['name' => Role::EDITOR]);
     Role::create(['name' => Role::AUTHOR]);
     Role::create(['name' => Role::CONTRIBUTOR]);
     Role::create(['name' => Role::SUBSCRIBER]);
 }
Example #5
0
 /** @test */
 public function it_signs_in()
 {
     $user = factory(User::class)->create(['password' => bcrypt('pass')]);
     $user->assignRole(Role::author());
     $this->visit(route('management.auth.create'))->type($user->email, 'email')->type('pass', 'password')->press('Sign In')->seePageIs(route('management.home'))->see('Authentication was successful.');
 }
Example #6
0
    $author = ['role_id' => \App\Gazette\Models\Role::author()->id];
    return array_merge($user, $author);
});
$factory->defineAs(App\Gazette\Models\User::class, 'user_editor', function ($faker) use($factory) {
    $user = $factory->raw(App\Gazette\Models\User::class);
    $author = ['role_id' => \App\Gazette\Models\Role::editor()->id];
    return array_merge($user, $author);
});
$factory->defineAs(App\Gazette\Models\User::class, 'user_contributor', function ($faker) use($factory) {
    $user = $factory->raw(App\Gazette\Models\User::class);
    $author = ['role_id' => \App\Gazette\Models\Role::contributor()->id];
    return array_merge($user, $author);
});
$factory->defineAs(App\Gazette\Models\User::class, 'user_subscriber', function ($faker) use($factory) {
    $user = $factory->raw(App\Gazette\Models\User::class);
    $author = ['role_id' => \App\Gazette\Models\Role::subscriber()->id];
    return array_merge($user, $author);
});
$factory->define(App\Gazette\Models\Role::class, function (Faker\Generator $faker) {
    return ['name' => $faker->name];
});
$factory->define(App\Gazette\Models\Post::class, function ($faker) use($factory) {
    $category = factory(App\Gazette\Models\Category::class)->create();
    $author = factory(App\Gazette\Models\User::class, 'user_author')->create();
    $title = $faker->name;
    $content = "<p>" . $faker->paragraph() . "</p><p>" . $faker->paragraph() . "</p><p>" . $faker->paragraph() . "</p>";
    return ['title' => $title, 'summary' => $faker->paragraphs(1, true), 'content' => $content, 'minutes_read' => $faker->numberBetween(1, 100), 'category_id' => $category->id, 'author_id' => $author->id, 'slug' => Str::slug($title), 'header_background' => $faker->imageUrl(1555, 1037), 'published' => $faker->boolean];
});
$factory->define(App\Gazette\Models\Category::class, function (Faker\Generator $faker) {
    $name = $faker->name;
    return ['name' => $name, 'avatar' => $faker->imageUrl(178, 298), 'slug' => Str::slug($name)];
Example #7
0
 public static function subscriber()
 {
     return Role::where('name', '=', Role::SUBSCRIBER)->first();
 }