Skip to content

Commit

Permalink
Try connection->execute() instead.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Apr 1, 2024
1 parent 04981a9 commit 23ba9c1
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions tests/TestCase/Command/SeedCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ protected function createTables(): void
{
$this->exec('migrations migrate -c test -s TestsMigrations --no-lock');
$this->assertExitSuccess();
var_dump($this->_out->messages());
var_dump($this->_err->messages());
$this->resetOutput();
}

Expand Down Expand Up @@ -118,8 +116,10 @@ public function testSeederOne(): void
$this->assertOutputContains('NumbersSeed:</info> <comment>seeding');
$this->assertOutputContains('All Done');

$numbers = $this->fetchTable('numbers');
$this->assertEquals(1, $numbers->find()->count());
/** @var \Cake\Database\Connection $connection */
$connection = ConnectionManager::get('test');
$query = $connection->execute('SELECT COUNT(*) FROM numbers');
$this->assertEquals(1, $query->fetchColumn(0));
}

public function testSeederMultipleNotFound(): void
Expand All @@ -141,11 +141,13 @@ public function testSeederMultiple(): void
$this->assertOutputContains('LettersSeed:</info> <comment>seeding');
$this->assertOutputContains('All Done');

$numbers = $this->fetchTable('numbers');
$this->assertEquals(1, $numbers->find()->count());
/** @var \Cake\Database\Connection $connection */
$connection = ConnectionManager::get('test');
$query = $connection->execute('SELECT COUNT(*) FROM numbers');
$this->assertEquals(1, $query->fetchColumn(0));

$letters = $this->fetchTable('letters');
$this->assertEquals(2, $letters->find()->count());
$query = $connection->execute('SELECT COUNT(*) FROM letters');
$this->assertEquals(2, $query->fetchColumn(0));
}

public function testSeederSourceNotFound(): void
Expand Down

0 comments on commit 23ba9c1

Please sign in to comment.