From 1e51748efc9ac8e74cc87d8e0b7ce6279865e3a2 Mon Sep 17 00:00:00 2001 From: johannebert Date: Tue, 4 Dec 2018 09:54:02 +0100 Subject: [PATCH 1/4] DB seed function in testing now accept an array too --- .../Foundation/Testing/Concerns/InteractsWithDatabase.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Illuminate/Foundation/Testing/Concerns/InteractsWithDatabase.php b/src/Illuminate/Foundation/Testing/Concerns/InteractsWithDatabase.php index 2895165c156f..c6e9abaccf19 100644 --- a/src/Illuminate/Foundation/Testing/Concerns/InteractsWithDatabase.php +++ b/src/Illuminate/Foundation/Testing/Concerns/InteractsWithDatabase.php @@ -84,12 +84,14 @@ protected function getConnection($connection = null) /** * Seed a given database connection. * - * @param string $class + * @param string|array $classes * @return $this */ - public function seed($class = 'DatabaseSeeder') + public function seed($classes = 'DatabaseSeeder') { - $this->artisan('db:seed', ['--class' => $class, '--no-interaction' => true]); + foreach ((array) $classes as $class) { + $this->artisan('db:seed', ['--class' => $class, '--no-interaction' => true]); + } return $this; } From 0b5ab5661fad162a89f92f6d95e2f50a9fcef802 Mon Sep 17 00:00:00 2001 From: johannebert Date: Tue, 4 Dec 2018 10:41:05 +0100 Subject: [PATCH 2/4] add Arr class to make array --- .../Foundation/Testing/Concerns/InteractsWithDatabase.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Illuminate/Foundation/Testing/Concerns/InteractsWithDatabase.php b/src/Illuminate/Foundation/Testing/Concerns/InteractsWithDatabase.php index c6e9abaccf19..191ace06b9f6 100644 --- a/src/Illuminate/Foundation/Testing/Concerns/InteractsWithDatabase.php +++ b/src/Illuminate/Foundation/Testing/Concerns/InteractsWithDatabase.php @@ -2,6 +2,7 @@ namespace Illuminate\Foundation\Testing\Concerns; +use Illuminate\Support\Arr; use Illuminate\Database\Eloquent\Model; use Illuminate\Foundation\Testing\Constraints\HasInDatabase; use PHPUnit\Framework\Constraint\LogicalNot as ReverseConstraint; @@ -84,12 +85,12 @@ protected function getConnection($connection = null) /** * Seed a given database connection. * - * @param string|array $classes + * @param string|array $class * @return $this */ - public function seed($classes = 'DatabaseSeeder') + public function seed($class = 'DatabaseSeeder') { - foreach ((array) $classes as $class) { + foreach (Arr::wrap($class) as $class) { $this->artisan('db:seed', ['--class' => $class, '--no-interaction' => true]); } From 6a1031168ec4c2ed15259790ecea0869a2f46104 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Tue, 4 Dec 2018 08:02:13 -0600 Subject: [PATCH 3/4] Update InteractsWithDatabase.php --- .../Foundation/Testing/Concerns/InteractsWithDatabase.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Foundation/Testing/Concerns/InteractsWithDatabase.php b/src/Illuminate/Foundation/Testing/Concerns/InteractsWithDatabase.php index 191ace06b9f6..8a1223ab6061 100644 --- a/src/Illuminate/Foundation/Testing/Concerns/InteractsWithDatabase.php +++ b/src/Illuminate/Foundation/Testing/Concerns/InteractsWithDatabase.php @@ -85,7 +85,7 @@ protected function getConnection($connection = null) /** * Seed a given database connection. * - * @param string|array $class + * @param array|string $class * @return $this */ public function seed($class = 'DatabaseSeeder') From adc2aeb897c48da7cc930a8b82170c073be1213d Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Tue, 4 Dec 2018 08:02:27 -0600 Subject: [PATCH 4/4] Update InteractsWithDatabase.php --- .../Foundation/Testing/Concerns/InteractsWithDatabase.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Foundation/Testing/Concerns/InteractsWithDatabase.php b/src/Illuminate/Foundation/Testing/Concerns/InteractsWithDatabase.php index 8a1223ab6061..843e4f6c0bdc 100644 --- a/src/Illuminate/Foundation/Testing/Concerns/InteractsWithDatabase.php +++ b/src/Illuminate/Foundation/Testing/Concerns/InteractsWithDatabase.php @@ -85,7 +85,7 @@ protected function getConnection($connection = null) /** * Seed a given database connection. * - * @param array|string $class + * @param array|string $class * @return $this */ public function seed($class = 'DatabaseSeeder')