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

Commit 5dca45d

Browse files
committed
Laravel 5.4 updates and test updates
1 parent 24fc74b commit 5dca45d

File tree

8 files changed

+55
-44
lines changed

8 files changed

+55
-44
lines changed

composer.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,17 @@
1515
"require": {
1616
"php": ">=5.6.4",
1717
"doctrine/dbal": "^2.5",
18-
"illuminate/support": "5.3.*",
19-
"yab/formmaker": "1.0.*",
20-
"yab/crudmaker": "1.1.*",
18+
"illuminate/support": "5.4.*",
19+
"yab/crudmaker": "1.2.*",
20+
"yab/formmaker": "1.1.*",
2121
"yab/crypto": "~1.0",
2222
"yab/cerebrum": "~1.0",
2323
"yab/laratest": "~0.1"
2424
},
2525
"require-dev": {
26-
"illuminate/container": "5.3.*",
2726
"mockery/mockery": "^0.9.4",
2827
"mikey179/vfsStream": "^1.6",
29-
"orchestra/testbench": "^3.3"
28+
"orchestra/testbench": "3.4.*|3.4-dev"
3029
},
3130
"autoload": {
3231
"psr-4": {
@@ -38,5 +37,6 @@
3837
"tests/TestCase.php"
3938
]
4039
},
41-
"minimum-stability": "stable"
40+
"minimum-stability": "dev",
41+
"prefer-stable": true
4242
}

src/Packages/Billing/tests/BillingIntegrationTest.php renamed to src/Packages/Billing/tests/Feature/BillingIntegrationTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,20 @@ public function testIndex()
2323
{
2424
$response = $this->actor->call('GET', '/user/billing/details');
2525
$this->assertEquals(200, $response->getStatusCode());
26-
$this->assertViewHas('user');
26+
$response->assertViewHas('user');
2727
}
2828

2929
public function testChangeCard()
3030
{
3131
$response = $this->actor->call('GET', '/user/billing/change-card');
3232
$this->assertEquals(200, $response->getStatusCode());
33-
$this->assertViewHas('user');
33+
$response->assertViewHas('user');
3434
}
3535

3636
public function testCoupon()
3737
{
3838
$response = $this->actor->call('GET', '/user/billing/coupon');
3939
$this->assertEquals(200, $response->getStatusCode());
40-
$this->assertViewHas('user');
40+
$response->assertViewHas('user');
4141
}
4242
}

src/Packages/Notifications/tests/NotificationIntegrationTest.php renamed to src/Packages/Notifications/tests/Feature/NotificationIntegrationTest.php

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22

3+
use Tests\TestCase;
34
use Illuminate\Foundation\Testing\WithoutMiddleware;
45
use Illuminate\Foundation\Testing\DatabaseMigrations;
56

@@ -30,15 +31,19 @@ public function setUp()
3031
'details' => 'Your car has been impounded!',
3132
'is_read' => 1,
3233
]);
33-
$user = factory({{App\}}Models\User::class)->make();
34+
35+
$role = factory({{App\}}Models\Role::class)->create();
36+
$user = factory({{App\}}Models\User::class)->create();
37+
$user->roles()->attach($role);
38+
3439
$this->actor = $this->actingAs($user);
3540
}
3641

3742
public function testIndex()
3843
{
3944
$response = $this->actor->call('GET', 'admin/notifications');
4045
$this->assertEquals(200, $response->getStatusCode());
41-
$this->assertViewHas('notifications');
46+
$response->assertViewHas('notifications');
4247
}
4348

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

5459
$this->assertEquals(302, $response->getStatusCode());
55-
$this->assertRedirectedTo('admin/notifications/'.$this->notification->id.'/edit');
60+
$response->assertRedirect('admin/notifications/'.$this->notification->id.'/edit');
5661
}
5762

5863
public function testEdit()
@@ -61,7 +66,7 @@ public function testEdit()
6166

6267
$response = $this->actor->call('GET', 'admin/notifications/'.$this->notification->id.'/edit');
6368
$this->assertEquals(200, $response->getStatusCode());
64-
$this->assertViewHas('notification');
69+
$response->assertViewHas('notification');
6570
}
6671

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

7277
$this->assertEquals(302, $response->getStatusCode());
73-
$this->seeInDatabase('notifications', $this->notificationEdited->toArray());
74-
$this->assertRedirectedTo('/');
78+
$this->assertDatabaseHas('notifications', $this->notificationEdited->toArray());
79+
$response->assertRedirect('/');
7580
}
7681

7782
public function testDelete()
@@ -80,6 +85,6 @@ public function testDelete()
8085

8186
$response = $this->call('DELETE', 'admin/notifications/'.$this->notification->id);
8287
$this->assertEquals(302, $response->getStatusCode());
83-
$this->assertRedirectedTo('admin/notifications');
88+
$response->assertRedirect('admin/notifications');
8489
}
8590
}

src/Packages/Notifications/tests/NotificationServiceTest.php renamed to src/Packages/Notifications/tests/Unit/NotificationServiceTest.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22

3+
use Tests\TestCase;
34
use {{App\}}Services\NotificationService;
45
use Illuminate\Foundation\Testing\DatabaseMigrations;
56

@@ -10,6 +11,10 @@ class NotificationServiceTest extends TestCase
1011
public function setUp()
1112
{
1213
parent::setUp();
14+
$role = factory({{App\}}Models\Role::class)->create();
15+
$user = factory({{App\}}Models\User::class)->create();
16+
$this->app->make({{App\}}Services\UserService::class)->create($user, 'password');
17+
1318
$this->service = $this->app->make(NotificationService::class);
1419
$this->originalArray = [
1520
'user_id' => 1,
@@ -55,7 +60,7 @@ public function testSearch()
5560
public function testCreate()
5661
{
5762
$response = $this->service->create($this->originalArray);
58-
$this->assertEquals(get_class($response), 'App\Models\Notification');
63+
$this->assertEquals(get_class($response), '{{App\}}Models\Notification');
5964
$this->assertEquals(1, $response->id);
6065
}
6166

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

7883
$this->assertEquals(1, $response->id);
79-
$this->seeInDatabase('notifications', $this->editedArray);
84+
$this->assertDatabaseHas('notifications', $this->editedArray);
8085
}
8186

8287
public function testDestroy()
@@ -87,6 +92,4 @@ public function testDestroy()
8792
$response = $this->service->destroy($item->id);
8893
$this->assertTrue($response);
8994
}
90-
9195
}
92-

src/Packages/Starter/tests/TeamIntegrationTest.php renamed to src/Packages/Starter/tests/Feature/TeamIntegrationTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function testIndex()
4444
{
4545
$response = $this->actor->call('GET', '/teams');
4646
$this->assertEquals(200, $response->getStatusCode());
47-
$this->assertViewHas('teams');
47+
$response->assertViewHas('teams');
4848
}
4949

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

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

6565
public function testEdit()
@@ -70,7 +70,7 @@ public function testEdit()
7070

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

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

8484
$this->assertEquals(302, $response->getStatusCode());
85-
$this->seeInDatabase('teams', $this->teamEdited->toArray());
86-
$this->assertRedirectedTo('/');
85+
$this->assertDatabaseHas('teams', $this->teamEdited->toArray());
86+
$response->assertRedirect('/');
8787
}
8888

8989
public function testDelete()
@@ -98,6 +98,6 @@ public function testDelete()
9898

9999
$response = $this->actingAs($admin)->call('DELETE', '/teams/'.$team->id);
100100
$this->assertEquals(302, $response->getStatusCode());
101-
$this->assertRedirectedTo('/teams');
101+
$response->assertRedirect('/teams');
102102
}
103103
}

src/Packages/Starter/tests/RoleServiceTest.php renamed to src/Packages/Starter/tests/Unit/RoleServiceTest.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22

3+
use Tests\TestCase;
34
use {{App\}}Services\RoleService;
45
use Illuminate\Foundation\Testing\DatabaseMigrations;
56

@@ -20,19 +21,19 @@ public function setUp()
2021
'id' => 1,
2122
'name' => 'coders',
2223
'label' => 'Coders',
23-
'permissions' => ['super' => 'on']
24+
'permissions' => ['super' => 'on'],
2425
];
2526
$this->modifiedArray = [
2627
'id' => 1,
2728
'name' => 'hackers',
2829
'label' => 'Hackers',
29-
'permissions' => []
30+
'permissions' => [],
3031
];
3132
$this->editedArray = [
3233
'id' => 1,
3334
'name' => 'hackers',
3435
'label' => 'Hackers',
35-
'permissions' => ''
36+
'permissions' => '',
3637
];
3738
$this->searchTerm = 'who';
3839
}
@@ -62,7 +63,7 @@ public function testSearch()
6263
public function testCreate()
6364
{
6465
$response = $this->service->create($this->originalArray);
65-
$this->assertEquals(get_class($response), 'App\Models\Role');
66+
$this->assertEquals(get_class($response), '{{App\}}Models\Role');
6667
$this->assertEquals(1, $response->id);
6768
}
6869

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

7475
$this->assertEquals($role->id, $response->id);
75-
$this->seeInDatabase('roles', $this->editedArray);
76+
$this->assertDatabaseHas('roles', $this->editedArray);
7677
}
7778

7879
public function testDestroy()

src/Packages/Starter/tests/TeamServiceTest.php renamed to src/Packages/Starter/tests/Unit/TeamServiceTest.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22

3+
use Tests\TestCase;
34
use {{App\}}Services\TeamService;
45
use {{App\}}Services\UserService;
56
use Illuminate\Foundation\Testing\DatabaseMigrations;
@@ -21,11 +22,11 @@ public function setUp()
2122

2223
$this->originalArray = [
2324
'user_id' => 1,
24-
'name' => 'Awesomeness'
25+
'name' => 'Awesomeness',
2526
];
2627
$this->editedArray = [
2728
'user_id' => 1,
28-
'name' => 'Hackers'
29+
'name' => 'Hackers',
2930
];
3031
$this->searchTerm = 'who';
3132
}
@@ -62,7 +63,7 @@ public function testCreate()
6263
{
6364
$user = factory({{App\}}Models\User::class)->create();
6465
$response = $this->service->create($user->id, $this->originalArray);
65-
$this->assertEquals(get_class($response), 'App\Models\Team');
66+
$this->assertEquals(get_class($response), '{{App\}}Models\Team');
6667
$this->assertEquals(1, $response->id);
6768
}
6869

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

103104
$this->assertEquals($team->id, $response->id);
104-
$this->seeInDatabase('teams', $this->editedArray);
105+
$this->assertDatabaseHas('teams', $this->editedArray);
105106
}
106107

107108
public function testDestroy()

src/Packages/Starter/tests/UserServiceTest.php renamed to src/Packages/Starter/tests/Unit/UserServiceTest.php

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22

3+
use Tests\TestCase;
34
use {{App\}}Services\UserService;
45
use Illuminate\Foundation\Testing\DatabaseMigrations;
56

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

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

4950
$response = $this->service->update($user->id, [
5051
'email' => $user->email,
@@ -53,20 +54,20 @@ public function testUpdateUser()
5354
'meta' => [
5455
'phone' => '666',
5556
'marketing' => 1,
56-
'terms_and_cond' => 1
57-
]
57+
'terms_and_cond' => 1,
58+
],
5859
]);
5960

60-
$this->seeInDatabase('user_meta', ['phone' => '666']);
61-
$this->seeInDatabase('users', ['name' => 'jim']);
61+
$this->assertDatabaseHas('user_meta', ['phone' => '666']);
62+
$this->assertDatabaseHas('users', ['name' => 'jim']);
6263
}
6364

6465
public function testAssignRole()
6566
{
6667
$role = factory({{App\}}Models\Role::class)->create();
6768
$user = factory({{App\}}Models\User::class)->create();
6869
$this->service->assignRole('member', $user->id);
69-
$this->seeInDatabase('role_user', ['role_id' => $role->id, 'user_id' => $user->id]);
70+
$this->assertDatabaseHas('role_user', ['role_id' => $role->id, 'user_id' => $user->id]);
7071
$this->assertEquals($user->roles->first()->label, 'Member');
7172
}
7273

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

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

0 commit comments

Comments
 (0)