Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 352347e

Browse files
Created separate suite to test the database seeder functionality
1 parent 83457ff commit 352347e

File tree

7 files changed

+81
-1
lines changed

7 files changed

+81
-1
lines changed

‎database/seeds/DatabaseSeeder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public function run()
1414
{
1515
Model::unguard();
1616

17-
// $this->call('UserTableSeeder');
17+
$this->call('UserTableSeeder');
1818
}
1919

2020
}

‎database/seeds/UserTableSeeder.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
use App\User;
4+
use Illuminate\Database\Seeder;
5+
6+
class UserTableSeeder extends Seeder
7+
{
8+
/**
9+
* Run the database seeds.
10+
*
11+
* @return void
12+
*/
13+
public function run()
14+
{
15+
User::create(['email' => 'johndoe@example.com', 'password' => bcrypt('password')]);
16+
}
17+
}

‎tests/_support/Helper/Seeder.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
namespace Helper;
3+
4+
// here you can define custom actions
5+
// all public methods declared in helper class will be available in $I
6+
7+
class Seeder extends \Codeception\Module
8+
{
9+
10+
}

‎tests/_support/SeederTester.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
4+
/**
5+
* Inherited Methods
6+
* @method void wantToTest($text)
7+
* @method void wantTo($text)
8+
* @method void execute($callable)
9+
* @method void expectTo($prediction)
10+
* @method void expect($prediction)
11+
* @method void amGoingTo($argumentation)
12+
* @method void am($role)
13+
* @method void lookForwardTo($achieveValue)
14+
* @method void comment($description)
15+
* @method \Codeception\Lib\Friend haveFriend($name, $actorClass = NULL)
16+
*
17+
* @SuppressWarnings(PHPMD)
18+
*/
19+
class SeederTester extends \Codeception\Actor
20+
{
21+
use _generated\SeederTesterActions;
22+
23+
/**
24+
* Define custom actions here
25+
*/
26+
}

‎tests/seeder.suite.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class_name: SeederTester
2+
modules:
3+
enabled:
4+
- \Helper\Seeder
5+
- Asserts
6+
- Laravel5:
7+
environment_file: .env.testing
8+
run_database_seeder: true
9+
database_seeder_class: DatabaseSeeder

‎tests/seeder/DatabaseSeederCest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
use App\User;
4+
5+
class DatabaseSeederCest
6+
{
7+
public function firstTest(SeederTester $I)
8+
{
9+
$I->assertCount(1, User::all());
10+
}
11+
12+
public function secondTest(SeederTester $I)
13+
{
14+
$I->assertCount(1, User::all());
15+
}
16+
}

‎tests/seeder/_bootstrap.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?php
2+
// Here you can initialize variables that will be available to your tests

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /