-
Notifications
You must be signed in to change notification settings - Fork 892
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added config option to specify custom seeder template path to use (#2146
) * Added config option to specify custom seeder template path to use * Fixed codestyle problems * Fixed code review problems * Update src/Phinx/Config/Config.php Fixing Code-Review problems Co-authored-by: Mark Scherer <dereuromark@users.noreply.github.com> * Fixed code review problems * Fixed code review problems * Fixed code review problems Co-authored-by: Mark Scherer <dereuromark@users.noreply.github.com>
- Loading branch information
1 parent
e43964d
commit f18dd21
Showing
7 changed files
with
230 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?php | ||
|
||
namespace Test\Phinx\Config; | ||
|
||
use Phinx\Config\Config; | ||
|
||
/** | ||
* Class ConfigSeedTemplatePathsTest | ||
* | ||
* @package Test\Phinx\Config | ||
* @group config | ||
* @covers \Phinx\Config\Config::getSeedTemplateFile | ||
*/ | ||
class ConfigSeedTemplatePathsTest extends AbstractConfigTest | ||
{ | ||
public function testTemplateAndPathAreSet() | ||
{ | ||
$values = [ | ||
'paths' => [ | ||
'seeds' => '/test', | ||
], | ||
'templates' => [ | ||
'seedFile' => 'seedFilePath', | ||
], | ||
]; | ||
|
||
$config = new Config($values); | ||
|
||
$actualValue = $config->getSeedTemplateFile(); | ||
$this->assertEquals('seedFilePath', $actualValue); | ||
} | ||
|
||
public function testTemplateIsSetButNoPath() | ||
{ | ||
// Here is used another key just to keep the node 'template' not empty | ||
$values = [ | ||
'paths' => [ | ||
'seeds' => '/test', | ||
], | ||
'templates' => [ | ||
'file' => 'migration_template_file', | ||
], | ||
]; | ||
|
||
$config = new Config($values); | ||
|
||
$actualValue = $config->getSeedTemplateFile(); | ||
$this->assertNull($actualValue); | ||
} | ||
|
||
public function testNoCustomSeedTemplate() | ||
{ | ||
$values = [ | ||
'paths' => [ | ||
'seeds' => '/test', | ||
], | ||
]; | ||
$config = new Config($values); | ||
|
||
$actualValue = $config->getSeedTemplateFile(); | ||
$this->assertNull($actualValue); | ||
|
||
$config->getSeedPaths(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
tests/Phinx/Console/Command/Templates/SimpleSeeder.templateFromConfig.php.dist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
useClassName $useClassName / className $className / baseClassName $baseClassName | ||
This file should be specified in config only, not in console runs |