Skip to content

Commit

Permalink
Merge pull request #597 from challgren/584-revert-596-fix
Browse files Browse the repository at this point in the history
Partially reverts #584
  • Loading branch information
dereuromark authored Dec 10, 2022
2 parents 3656173 + da4afa7 commit bbe44b6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
8 changes: 1 addition & 7 deletions src/ConfigurationTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,7 @@ public function getConfig($forceRefresh = false): ConfigInterface
mkdir($migrationsPath, 0777, true);
}

if (!is_dir($seedsPath)) {
if (!Configure::read('debug')) {
throw new \RuntimeException(sprintf(
'Seeds path `%s` does not exist and cannot be created because `debug` is disabled.',
$seedsPath
));
}
if (Configure::read('debug') && !is_dir($seedsPath)) {
mkdir($seedsPath, 0777, true);
}

Expand Down
15 changes: 10 additions & 5 deletions tests/TestCase/ConfigurationTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -335,18 +335,23 @@ public function testGetConfigNoMigrationsFolderDebugDisabled()
*/
public function testGetConfigNoSeedsFolderDebugDisabled()
{
ConnectionManager::setConfig('default', [
'className' => 'Cake\Database\Connection',
'driver' => 'Cake\Database\Driver\Mysql',
'host' => 'foo.bar',
'username' => 'root',
'password' => 'the_password',
'database' => 'the_database',
'encoding' => 'utf-8',
]);
Configure::write('debug', false);

$migrationsPath = ROOT . DS . 'config' . DS . 'TestGetConfigMigrations';
mkdir($migrationsPath, 0777, true);
$seedsPath = ROOT . DS . 'config' . DS . 'TestGetConfigSeeds';

$command = $this->_getCommandMock($migrationsPath, $seedsPath);
$this->expectException(\RuntimeException::class);
$this->expectExceptionMessage(sprintf(
'Seeds path `%s` does not exist and cannot be created because `debug` is disabled.',
$seedsPath
));
$this->assertFalse(is_dir($seedsPath));
try {
$config = $command->getConfig();
} finally {
Expand Down

0 comments on commit bbe44b6

Please sign in to comment.