Skip to content

Commit

Permalink
Add new seed tests files for php 8.1
Browse files Browse the repository at this point in the history
  • Loading branch information
ajibarra committed Sep 9, 2022
1 parent e91de95 commit a992608
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tests/TestCase/Command/BakeSeedCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ public function testWithData()
$path = __FUNCTION__ . '.php';
if (getenv('DB') === 'pgsql') {
$path = getenv('DB') . DS . $path;
} elseif (PHP_VERSION_ID >= 80100) {
$path = 'php81' . DS . $path;
}

$this->assertExitCode(BaseCommand::CODE_SUCCESS);
Expand Down Expand Up @@ -115,6 +117,8 @@ public function testWithDataAndLimit()
$path = __FUNCTION__ . '.php';
if (getenv('DB') === 'pgsql') {
$path = getenv('DB') . DS . $path;
} elseif (PHP_VERSION_ID >= 80100) {
$path = 'php81' . DS . $path;
}

$this->assertExitCode(BaseCommand::CODE_SUCCESS);
Expand Down
51 changes: 51 additions & 0 deletions tests/comparisons/Seeds/php81/testWithData.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php
declare(strict_types=1);

use Migrations\AbstractSeed;

/**
* Events seed.
*/
class EventsSeed extends AbstractSeed
{
/**
* Run Method.
*
* Write your database seeder using this method.
*
* More information on writing seeds is available here:
* https://book.cakephp.org/phinx/0/en/seeding.html
*
* @return void
*/
public function run()
{
$data = [
[
'id' => 1,
'title' => 'Lorem ipsum dolor sit amet',
'description' => 'Lorem ipsum dolor sit amet, aliquet feugiat.',
'published' => 'Y',
],
[
'id' => 2,
'title' => 'Second event',
'description' => 'Second event description.',
'published' => 'Y',
],
[
'id' => 3,
'title' => 'Lorem ipsum dolor sit amet',
'description' => 'Lorem ipsum dolor sit amet, aliquet feugiat.
Convallis morbi fringilla gravida, phasellus feugiat dapibus velit nunc, pulvinar eget \'sollicitudin\' venenatis cum
nullam, vivamus ut a sed, mollitia lectus.
Nulla vestibulum massa neque ut et, id hendrerit sit, feugiat in taciti enim proin nibh, tempor dignissim, rhoncus
duis vestibulum nunc mattis convallis.',
'published' => 'Y',
],
];

$table = $this->table('events');
$table->insert($data)->save();
}
}
41 changes: 41 additions & 0 deletions tests/comparisons/Seeds/php81/testWithDataAndLimit.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php
declare(strict_types=1);

use Migrations\AbstractSeed;

/**
* Events seed.
*/
class EventsSeed extends AbstractSeed
{
/**
* Run Method.
*
* Write your database seeder using this method.
*
* More information on writing seeds is available here:
* https://book.cakephp.org/phinx/0/en/seeding.html
*
* @return void
*/
public function run()
{
$data = [
[
'id' => 1,
'title' => 'Lorem ipsum dolor sit amet',
'description' => 'Lorem ipsum dolor sit amet, aliquet feugiat.',
'published' => 'Y',
],
[
'id' => 2,
'title' => 'Second event',
'description' => 'Second event description.',
'published' => 'Y',
],
];

$table = $this->table('events');
$table->insert($data)->save();
}
}

0 comments on commit a992608

Please sign in to comment.