Skip to content

Commit db00236

Browse files
committed
Added more tests
1 parent 351e39c commit db00236

File tree

3 files changed

+45
-25
lines changed

3 files changed

+45
-25
lines changed

composer.lock

Lines changed: 16 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

database/factories/UserFactory.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,18 @@
99

1010
// Model Factories
1111

12-
/** @var Factory $factory */
13-
14-
$factory->define(User::class, function (Faker $faker) {
12+
$attributes = function (Faker $faker) {
1513
return [
1614
'name' => $faker->name,
1715
'email' => $faker->unique()->safeEmail,
1816
'email_verified_at' => now(),
1917
'password' => 'secret',
2018
'remember_token' => Str::random(10),
2119
];
22-
});
20+
};
21+
22+
/** @var Factory $factory */
23+
24+
$factory->define(User::class, $attributes);
25+
26+
$factory->defineAs(User::class, 'admin', $attributes);

tests/Functional/LaravelModuleCest.php

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use App\Utils\ToUppercase;
1313
use Illuminate\Contracts\Config\Repository as Config;
1414
use Illuminate\Contracts\Http\Kernel;
15+
use Illuminate\Database\Eloquent\Collection;
1516
use Illuminate\Foundation\Application;
1617
use Tests\FunctionalTester;
1718

@@ -37,7 +38,8 @@ public function amOnAction(FunctionalTester $I)
3738

3839
public function amOnRoute(FunctionalTester $I)
3940
{
40-
// TODO
41+
$I->amOnRoute('test-value');
42+
$I->see('Test value is');
4143
}
4244

4345
public function callArtisan(FunctionalTester $I)
@@ -182,7 +184,13 @@ public function grabService(FunctionalTester $I)
182184

183185
public function have(FunctionalTester $I)
184186
{
185-
// TODO
187+
$user = $I->have(User::class, ['email' => 'johndoe@example.com']);
188+
189+
$I->assertEquals('johndoe@example.com', $user->email);
190+
$I->seeRecord('users', ['email' => 'johndoe@example.com']);
191+
192+
// Create one with name
193+
$I->have(User::class, [], 'admin');
186194
}
187195

188196
public function haveApplicationHandler(FunctionalTester $I)
@@ -230,7 +238,9 @@ public function haveInstance(FunctionalTester $I)
230238

231239
public function haveMultiple(FunctionalTester $I)
232240
{
233-
// TODO
241+
$I->haveMultiple(User::class, 3);
242+
243+
$I->seeNumRecords(4, User::class);
234244
}
235245

236246
public function haveRecord(FunctionalTester $I)
@@ -268,12 +278,18 @@ public function logout(FunctionalTester $I)
268278

269279
public function make(FunctionalTester $I)
270280
{
271-
// TODO
281+
/** @var Collection $collection */
282+
$collection = $I->make(User::class, ['email' => 'johndoe@example.com']);
283+
284+
$I->assertInstanceOf(User::class, $collection->first());
272285
}
273286

274287
public function makeMultiple(FunctionalTester $I)
275288
{
276-
// TODO
289+
/** @var Collection $collection */
290+
$collection = $I->makeMultiple(User::class, 3);
291+
292+
$I->assertSame(3, $collection->count());
277293
}
278294

279295
public function seeAuthentication(FunctionalTester $I)

0 commit comments

Comments
 (0)