diff --git a/lib/Cake/Console/Command/Task/FixtureTask.php b/lib/Cake/Console/Command/Task/FixtureTask.php index 8056aeefe51..3f75f98571c 100644 --- a/lib/Cake/Console/Command/Task/FixtureTask.php +++ b/lib/Cake/Console/Command/Task/FixtureTask.php @@ -1,9 +1,5 @@ null, 'schema' => null, 'records' => null, 'import' => null, 'fields' => null); + $defaults = [ + 'table' => null, + 'schema' => null, + 'records' => null, + 'import' => null, + 'fields' => null, + 'namespace' => Configure::read('App.namespace') + ]; + if ($this->plugin) { + $defaults['namespace'] = $this->plugin; + } $vars = array_merge($defaults, $otherVars); $path = $this->getPath(); diff --git a/lib/Cake/Console/Templates/default/classes/fixture.ctp b/lib/Cake/Console/Templates/default/classes/fixture.ctp index fa2971a1c04..d7124c299dd 100644 --- a/lib/Cake/Console/Templates/default/classes/fixture.ctp +++ b/lib/Cake/Console/Templates/default/classes/fixture.ctp @@ -20,11 +20,15 @@ */ ?> +namespace \Test\Fixture; + +use Cake\TestSuite\Fixture\TestFixture; + /** * Fixture * */ -class Fixture extends \Cake\TestSuite\Fixture\TestFixture { +class Fixture extends TestFixture { /** diff --git a/lib/Cake/Test/TestCase/Console/Command/Task/FixtureTaskTest.php b/lib/Cake/Test/TestCase/Console/Command/Task/FixtureTaskTest.php index e0ca5d6ad04..5dc059d5ff1 100644 --- a/lib/Cake/Test/TestCase/Console/Command/Task/FixtureTaskTest.php +++ b/lib/Cake/Test/TestCase/Console/Command/Task/FixtureTaskTest.php @@ -1,9 +1,5 @@ true, 'schema' => 'Article', 'records' => false )); - $this->assertContains('class ArticleFixture extends CakeTestFixture', $result); + $this->assertContains('namespace App\Test\Fixture;', $result); + $this->assertContains('use Cake\TestSuite\Fixture\TestFixture;', $result); + $this->assertContains('class ArticleFixture extends TestFixture', $result); $this->assertContains('public $records', $result); $this->assertContains('public $import', $result); $this->assertContains("'title' => 'First Article'", $result, 'Missing import data %s'); @@ -302,13 +299,13 @@ public function testBake() { $this->Task->path = '/my/path/'; $result = $this->Task->bake('Article'); - $this->assertContains('class ArticleFixture extends CakeTestFixture', $result); + $this->assertContains('class ArticleFixture extends TestFixture', $result); $this->assertContains('public $fields', $result); $this->assertContains('public $records', $result); $this->assertNotContains('public $import', $result); $result = $this->Task->bake('Article', 'comments'); - $this->assertContains('class ArticleFixture extends CakeTestFixture', $result); + $this->assertContains('class ArticleFixture extends TestFixture', $result); $this->assertContains('public $table = \'comments\';', $result); $this->assertContains('public $fields = array(', $result); diff --git a/lib/Cake/Test/TestCase/Console/Command/Task/TemplateTaskTest.php b/lib/Cake/Test/TestCase/Console/Command/Task/TemplateTaskTest.php index bcdc460a187..9359c435d10 100644 --- a/lib/Cake/Test/TestCase/Console/Command/Task/TemplateTaskTest.php +++ b/lib/Cake/Test/TestCase/Console/Command/Task/TemplateTaskTest.php @@ -156,7 +156,8 @@ public function testGenerateWithTemplateFallbacks() { 'table' => 'articles', 'import' => false, 'records' => false, - 'schema' => '' + 'schema' => '', + 'namespace' => '' )); $result = $this->Task->generate('classes', 'fixture'); $this->assertRegExp('/ArticleFixture extends .*TestFixture/', $result);