Skip to content

Commit

Permalink
Added Organiser Events Test fixed model factory
Browse files Browse the repository at this point in the history
  • Loading branch information
bretto36 committed Jun 17, 2016
1 parent adf16e7 commit ea5d4fa
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 25 deletions.
1 change: 0 additions & 1 deletion app/Http/Controllers/OrganiserDashboardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use App\Models\Organiser;
use Carbon\Carbon;
use DB;

class OrganiserDashboardController extends MyBaseController
{
Expand Down
1 change: 0 additions & 1 deletion app/Http/Controllers/OrganiserEventsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

class OrganiserEventsController extends MyBaseController
{

/**
* Show the organiser events page
*
Expand Down
1 change: 0 additions & 1 deletion app/Http/Controllers/OrganiserViewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

class OrganiserViewController extends Controller
{

/**
* Show the public organiser page
*
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function postEditUser(Request $request)

return response()->json([
'status' => 'success',
'message' => 'Successfully Edited User',
'message' => 'Successfully Saved Details',
]);
}
}
2 changes: 1 addition & 1 deletion database/factories/ModelFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@

$factory->define(App\Models\Event::class, function (Faker\Generator $faker) {
return [
'title' => $faker->title,
'title' => $faker->name,
'location' => $faker->text,
'bg_type' => 'color',
'bg_color' => config('attendize.event_default_bg_color'),
Expand Down
26 changes: 26 additions & 0 deletions tests/OrganiserCustomizeTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use App\Models\Organiser;

class OrganiserCustomizeTest extends TestCase
{
public function test_customize_organiser_is_successful()
{
$organiser = factory(App\Models\Organiser::class)->create();

$this->actingAs($this->test_user)
->visit(route('showOrganiserCustomize', ['organiser_id' => $organiser->id]))
->type($this->faker->name, 'name')
->type($this->faker->email, 'email')
->type($this->faker->email, 'about')
->type($this->faker->word, 'facebook')
->type($this->faker->word, 'twitter')
->press('Create Organiser')
->seeJson([
'status' => 'success'
]);
}
}
32 changes: 32 additions & 0 deletions tests/OrganiserEventsTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use App\Models\Organiser;

class OrganiserEventsTest extends TestCase
{
public function test_show_events_displays_events()
{
$organiser = factory(App\Models\Organiser::class)->create(['account_id' => 1]);

$event1 = factory(App\Models\Event::class)->create([
'account_id' => $organiser->account_id,
'organiser_id' => $organiser->id,
'user_id' => $this->test_user->id,
]);

$event2 = factory(App\Models\Event::class)->create([
'account_id' => $organiser->account_id,
'organiser_id' => $organiser->id,
'user_id' => $this->test_user->id,
]);

$this->actingAs($this->test_user)
->visit(route('showOrganiserEvents', ['organiser_id' => $organiser->id]))
->see($event1->title)
->see($event2->title)
->see('2 events');
}
}
19 changes: 1 addition & 18 deletions tests/OrganiserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class OrganiserTest extends TestCase
{
public function testCreateOrganiser()
public function test_create_organiser_is_successful()
{
$this->actingAs($this->test_user)
->visit(route('showCreateOrganiser'))
Expand All @@ -21,21 +21,4 @@ public function testCreateOrganiser()
'status' => 'success'
]);
}

public function testEditOrganiser()
{
$organiser = factory(App\Models\Organiser::class)->create();

$this->actingAs($this->test_user)
->visit(route('showOrganiserCustomize', ['organiser_id' => $organiser->id]))
->type($this->faker->name, 'name')
->type($this->faker->email, 'email')
->type($this->faker->email, 'about')
->type($this->faker->word, 'facebook')
->type($this->faker->word, 'twitter')
->press('Create Organiser')
->seeJson([
'status' => 'success'
]);
}
}
4 changes: 2 additions & 2 deletions tests/UserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function test_edit_user_is_successful()

$this->seeJson([
'status' => 'success',
'message' => 'Successfully Edited User',
'message' => 'Successfully Saved Details',
]);

$user = App\Models\User::find($this->test_user->id);
Expand Down Expand Up @@ -64,7 +64,7 @@ public function test_edit_user_is_successful_when_changing_password()

$this->seeJson([
'status' => 'success',
'message' => 'Successfully Edited User',
'message' => 'Successfully Saved Details',
]);

$user = App\Models\User::find($this->test_user->id);
Expand Down

0 comments on commit ea5d4fa

Please sign in to comment.