Skip to content
This repository has been archived by the owner on Jan 10, 2020. It is now read-only.

Commit

Permalink
Laravel 5.4 updates and test updates
Browse files Browse the repository at this point in the history
  • Loading branch information
mlantz committed Jan 27, 2017
1 parent 24fc74b commit 5dca45d
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 44 deletions.
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,17 @@
"require": {
"php": ">=5.6.4",
"doctrine/dbal": "^2.5",
"illuminate/support": "5.3.*",
"yab/formmaker": "1.0.*",
"yab/crudmaker": "1.1.*",
"illuminate/support": "5.4.*",
"yab/crudmaker": "1.2.*",
"yab/formmaker": "1.1.*",
"yab/crypto": "~1.0",
"yab/cerebrum": "~1.0",
"yab/laratest": "~0.1"
},
"require-dev": {
"illuminate/container": "5.3.*",
"mockery/mockery": "^0.9.4",
"mikey179/vfsStream": "^1.6",
"orchestra/testbench": "^3.3"
"orchestra/testbench": "3.4.*|3.4-dev"
},
"autoload": {
"psr-4": {
Expand All @@ -38,5 +37,6 @@
"tests/TestCase.php"
]
},
"minimum-stability": "stable"
"minimum-stability": "dev",
"prefer-stable": true
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,20 @@ public function testIndex()
{
$response = $this->actor->call('GET', '/user/billing/details');
$this->assertEquals(200, $response->getStatusCode());
$this->assertViewHas('user');
$response->assertViewHas('user');
}

public function testChangeCard()
{
$response = $this->actor->call('GET', '/user/billing/change-card');
$this->assertEquals(200, $response->getStatusCode());
$this->assertViewHas('user');
$response->assertViewHas('user');
}

public function testCoupon()
{
$response = $this->actor->call('GET', '/user/billing/coupon');
$this->assertEquals(200, $response->getStatusCode());
$this->assertViewHas('user');
$response->assertViewHas('user');
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

use Tests\TestCase;
use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\DatabaseMigrations;

Expand Down Expand Up @@ -30,15 +31,19 @@ public function setUp()
'details' => 'Your car has been impounded!',
'is_read' => 1,
]);
$user = factory({{App\}}Models\User::class)->make();

$role = factory({{App\}}Models\Role::class)->create();
$user = factory({{App\}}Models\User::class)->create();
$user->roles()->attach($role);

$this->actor = $this->actingAs($user);
}

public function testIndex()
{
$response = $this->actor->call('GET', 'admin/notifications');
$this->assertEquals(200, $response->getStatusCode());
$this->assertViewHas('notifications');
$response->assertViewHas('notifications');
}

public function testCreate()
Expand All @@ -52,7 +57,7 @@ public function testStore()
$response = $this->actor->call('POST', 'admin/notifications', $this->notification->toArray());

$this->assertEquals(302, $response->getStatusCode());
$this->assertRedirectedTo('admin/notifications/'.$this->notification->id.'/edit');
$response->assertRedirect('admin/notifications/'.$this->notification->id.'/edit');
}

public function testEdit()
Expand All @@ -61,7 +66,7 @@ public function testEdit()

$response = $this->actor->call('GET', 'admin/notifications/'.$this->notification->id.'/edit');
$this->assertEquals(200, $response->getStatusCode());
$this->assertViewHas('notification');
$response->assertViewHas('notification');
}

public function testUpdate()
Expand All @@ -70,8 +75,8 @@ public function testUpdate()
$response = $this->actor->call('PATCH', 'admin/notifications/1', $this->notificationEdited->toArray());

$this->assertEquals(302, $response->getStatusCode());
$this->seeInDatabase('notifications', $this->notificationEdited->toArray());
$this->assertRedirectedTo('/');
$this->assertDatabaseHas('notifications', $this->notificationEdited->toArray());
$response->assertRedirect('/');
}

public function testDelete()
Expand All @@ -80,6 +85,6 @@ public function testDelete()

$response = $this->call('DELETE', 'admin/notifications/'.$this->notification->id);
$this->assertEquals(302, $response->getStatusCode());
$this->assertRedirectedTo('admin/notifications');
$response->assertRedirect('admin/notifications');
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

use Tests\TestCase;
use {{App\}}Services\NotificationService;
use Illuminate\Foundation\Testing\DatabaseMigrations;

Expand All @@ -10,6 +11,10 @@ class NotificationServiceTest extends TestCase
public function setUp()
{
parent::setUp();
$role = factory({{App\}}Models\Role::class)->create();
$user = factory({{App\}}Models\User::class)->create();
$this->app->make({{App\}}Services\UserService::class)->create($user, 'password');

$this->service = $this->app->make(NotificationService::class);
$this->originalArray = [
'user_id' => 1,
Expand Down Expand Up @@ -55,7 +60,7 @@ public function testSearch()
public function testCreate()
{
$response = $this->service->create($this->originalArray);
$this->assertEquals(get_class($response), 'App\Models\Notification');
$this->assertEquals(get_class($response), '{{App\}}Models\Notification');
$this->assertEquals(1, $response->id);
}

Expand All @@ -76,7 +81,7 @@ public function testUpdate()
$response = $this->service->update($item->id, $this->editedArray);

$this->assertEquals(1, $response->id);
$this->seeInDatabase('notifications', $this->editedArray);
$this->assertDatabaseHas('notifications', $this->editedArray);
}

public function testDestroy()
Expand All @@ -87,6 +92,4 @@ public function testDestroy()
$response = $this->service->destroy($item->id);
$this->assertTrue($response);
}

}

Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function testIndex()
{
$response = $this->actor->call('GET', '/teams');
$this->assertEquals(200, $response->getStatusCode());
$this->assertViewHas('teams');
$response->assertViewHas('teams');
}

public function testCreate()
Expand All @@ -59,7 +59,7 @@ public function testStore()
$response = $this->actingAs($admin)->call('POST', 'teams', $this->team->toArray());

$this->assertEquals(302, $response->getStatusCode());
$this->assertRedirectedTo('teams/'.$this->team->id.'/edit');
$response->assertRedirect('teams/'.$this->team->id.'/edit');
}

public function testEdit()
Expand All @@ -70,7 +70,7 @@ public function testEdit()

$response = $this->actingAs($admin)->call('GET', '/teams/'.$this->team->id.'/edit');
$this->assertEquals(200, $response->getStatusCode());
$this->assertViewHas('team');
$response->assertViewHas('team');
}

public function testUpdate()
Expand All @@ -82,8 +82,8 @@ public function testUpdate()
$response = $this->actingAs($admin)->call('PATCH', '/teams/1', $this->teamEdited->toArray());

$this->assertEquals(302, $response->getStatusCode());
$this->seeInDatabase('teams', $this->teamEdited->toArray());
$this->assertRedirectedTo('/');
$this->assertDatabaseHas('teams', $this->teamEdited->toArray());
$response->assertRedirect('/');
}

public function testDelete()
Expand All @@ -98,6 +98,6 @@ public function testDelete()

$response = $this->actingAs($admin)->call('DELETE', '/teams/'.$team->id);
$this->assertEquals(302, $response->getStatusCode());
$this->assertRedirectedTo('/teams');
$response->assertRedirect('/teams');
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

use Tests\TestCase;
use {{App\}}Services\RoleService;
use Illuminate\Foundation\Testing\DatabaseMigrations;

Expand All @@ -20,19 +21,19 @@ public function setUp()
'id' => 1,
'name' => 'coders',
'label' => 'Coders',
'permissions' => ['super' => 'on']
'permissions' => ['super' => 'on'],
];
$this->modifiedArray = [
'id' => 1,
'name' => 'hackers',
'label' => 'Hackers',
'permissions' => []
'permissions' => [],
];
$this->editedArray = [
'id' => 1,
'name' => 'hackers',
'label' => 'Hackers',
'permissions' => ''
'permissions' => '',
];
$this->searchTerm = 'who';
}
Expand Down Expand Up @@ -62,7 +63,7 @@ public function testSearch()
public function testCreate()
{
$response = $this->service->create($this->originalArray);
$this->assertEquals(get_class($response), 'App\Models\Role');
$this->assertEquals(get_class($response), '{{App\}}Models\Role');
$this->assertEquals(1, $response->id);
}

Expand All @@ -72,7 +73,7 @@ public function testUpdate()
$response = $this->service->update($role->id, $this->modifiedArray);

$this->assertEquals($role->id, $response->id);
$this->seeInDatabase('roles', $this->editedArray);
$this->assertDatabaseHas('roles', $this->editedArray);
}

public function testDestroy()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

use Tests\TestCase;
use {{App\}}Services\TeamService;
use {{App\}}Services\UserService;
use Illuminate\Foundation\Testing\DatabaseMigrations;
Expand All @@ -21,11 +22,11 @@ public function setUp()

$this->originalArray = [
'user_id' => 1,
'name' => 'Awesomeness'
'name' => 'Awesomeness',
];
$this->editedArray = [
'user_id' => 1,
'name' => 'Hackers'
'name' => 'Hackers',
];
$this->searchTerm = 'who';
}
Expand Down Expand Up @@ -62,7 +63,7 @@ public function testCreate()
{
$user = factory({{App\}}Models\User::class)->create();
$response = $this->service->create($user->id, $this->originalArray);
$this->assertEquals(get_class($response), 'App\Models\Team');
$this->assertEquals(get_class($response), '{{App\}}Models\Team');
$this->assertEquals(1, $response->id);
}

Expand Down Expand Up @@ -101,7 +102,7 @@ public function testUpdate()
$response = $this->service->update($team->id, $this->editedArray);

$this->assertEquals($team->id, $response->id);
$this->seeInDatabase('teams', $this->editedArray);
$this->assertDatabaseHas('teams', $this->editedArray);
}

public function testDestroy()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

use Tests\TestCase;
use {{App\}}Services\UserService;
use Illuminate\Foundation\Testing\DatabaseMigrations;

Expand All @@ -24,7 +25,7 @@ public function testGetUsers()
public function testGetUser()
{
$user = factory({{App\}}Models\User::class)->create();
factory({{App\}}Models\UserMeta::class)->create([ 'user_id' => $user->id ]);
factory({{App\}}Models\UserMeta::class)->create(['user_id' => $user->id]);
$response = $this->service->find($user->id);

$this->assertTrue(is_object($response));
Expand All @@ -44,7 +45,7 @@ public function testCreateUser()
public function testUpdateUser()
{
$user = factory({{App\}}Models\User::class)->create();
factory({{App\}}Models\UserMeta::class)->create([ 'user_id' => $user->id ]);
factory({{App\}}Models\UserMeta::class)->create(['user_id' => $user->id]);

$response = $this->service->update($user->id, [
'email' => $user->email,
Expand All @@ -53,20 +54,20 @@ public function testUpdateUser()
'meta' => [
'phone' => '666',
'marketing' => 1,
'terms_and_cond' => 1
]
'terms_and_cond' => 1,
],
]);

$this->seeInDatabase('user_meta', ['phone' => '666']);
$this->seeInDatabase('users', ['name' => 'jim']);
$this->assertDatabaseHas('user_meta', ['phone' => '666']);
$this->assertDatabaseHas('users', ['name' => 'jim']);
}

public function testAssignRole()
{
$role = factory({{App\}}Models\Role::class)->create();
$user = factory({{App\}}Models\User::class)->create();
$this->service->assignRole('member', $user->id);
$this->seeInDatabase('role_user', ['role_id' => $role->id, 'user_id' => $user->id]);
$this->assertDatabaseHas('role_user', ['role_id' => $role->id, 'user_id' => $user->id]);
$this->assertEquals($user->roles->first()->label, 'Member');
}

Expand All @@ -75,7 +76,7 @@ public function testHasRole()
$role = factory({{App\}}Models\Role::class)->create();
$user = factory({{App\}}Models\User::class)->create();
$this->service->assignRole('member', $user->id);
$this->seeInDatabase('role_user', ['role_id' => $role->id, 'user_id' => $user->id]);
$this->assertDatabaseHas('role_user', ['role_id' => $role->id, 'user_id' => $user->id]);
$this->assertTrue($user->hasRole('member'));
}

Expand All @@ -102,7 +103,7 @@ public function testJoinTeam()
$team = factory({{App\}}Models\Team::class)->create();
$user = factory({{App\}}Models\User::class)->create();
$this->service->joinTeam($team->id, $user->id);
$this->seeInDatabase('team_user', ['team_id' => $team->id, 'user_id' => $user->id]);
$this->assertDatabaseHas('team_user', ['team_id' => $team->id, 'user_id' => $user->id]);
$this->assertEquals($user->teams->first()->name, $team->name);
}

Expand Down

0 comments on commit 5dca45d

Please sign in to comment.