Skip to content

Commit

Permalink
Merge branch '3.next'
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Dec 12, 2018
2 parents 8a675e3 + b69b920 commit 336a97f
Show file tree
Hide file tree
Showing 24 changed files with 151 additions and 118 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
},
"require": {
"php": ">=5.6.0",
"cakephp/cakephp": "^3.6.12",
"cakephp/cakephp": "^3.7.0",
"cakephp/plugin-installer": "^1.0",
"wyrihaximus/twig-view": "^4.3.4"
},
Expand Down
2 changes: 1 addition & 1 deletion src/Shell/BakeShell.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function startup()
Configure::write('debug', true);
Cache::disable();
// Loading WyriHaximus/TwigView Plugin through the Plugin::load() for backward compatibility.
if (!Plugin::loaded('WyriHaximus/TwigView')) {
if (!Plugin::isLoaded('WyriHaximus/TwigView')) {
Plugin::load('WyriHaximus/TwigView', ['bootstrap' => true]);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Shell/Task/ModelTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ public function getAssociationInfo(Table $table)
if ($tableClass === 'Cake\ORM\Table') {
$namespace = $appNamespace;

$className = $association->className();
$className = $association->getClassName();
if (strlen($className)) {
list($plugin, $className) = pluginSplit($className);
if ($plugin !== null) {
Expand Down
2 changes: 1 addition & 1 deletion src/Shell/Task/TestTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ protected function _processController($subject)
protected function _addFixture($name)
{
if ($this->plugin) {
$prefix = 'plugin.' . Inflector::underscore($this->plugin) . '.';
$prefix = 'plugin.' . $this->plugin . '.';
} else {
$prefix = 'app.';
}
Expand Down
16 changes: 10 additions & 6 deletions src/Template/Bake/tests/test_case.twig
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@
{% set isShell = type|lower == 'shell' %}
{% set isCommand = type|lower == 'command' %}
{% if isController %}
{%- set superClassName = 'IntegrationTestCase' %}
{%- set traitName = 'IntegrationTestTrait' %}
{% elseif isShell or isCommand %}
{%- set superClassName = 'ConsoleIntegrationTestCase' %}
{% else %}
{%- set superClassName = 'TestCase' %}
{%- set traitName = 'ConsoleIntegrationTestTrait' %}
{% endif %}
{%- set uses = uses|merge(["Cake\\TestSuite\\TestCase"]) %}
{% if traitName %}
{%- set uses = uses|merge(["Cake\\TestSuite\\#{traitName}"]) %}
{% endif %}
{%- set uses = uses|merge(["Cake\\TestSuite\\#{superClassName}"]) %}

{%- set uses = uses|sort %}
<?php
Expand All @@ -38,8 +39,11 @@ use {{ dependency }};
/**
* {{ fullClassName }} Test Case
*/
class {{ className }}Test extends {{ superClassName }}
class {{ className }}Test extends TestCase
{
{% if traitName %}
use {{ traitName }};
{% endif %}
{% if properties %}
{% for propertyInfo in properties %}
Expand Down
4 changes: 2 additions & 2 deletions src/View/BakeView.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,10 @@ public function render($view = null, $layout = null)

$this->_currentType = static::TYPE_TEMPLATE;
$this->dispatchEvent('View.beforeRender', [$viewFileName]);
$this->dispatchEvent('View.beforeRender.' . $templateEventName, [$viewFileName]);
$this->dispatchEvent('View.beforeRender' . $templateEventName, [$viewFileName]);
$this->Blocks->set('content', $this->_render($viewFileName));
$this->dispatchEvent('View.afterRender', [$viewFileName]);
$this->dispatchEvent('View.afterRender.' . $templateEventName, [$viewFileName]);
$this->dispatchEvent('View.afterRender' . $templateEventName, [$viewFileName]);

if ($layout === null) {
$layout = $this->layout;
Expand Down
15 changes: 8 additions & 7 deletions tests/TestCase/Shell/BakeShellTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class BakeShellTest extends TestCase
*
* @var array
*/
public $fixtures = ['core.comments'];
public $fixtures = ['core.Comments'];

/**
* @var ConsoleOutput
Expand Down Expand Up @@ -195,7 +195,6 @@ public function testMain()
{
$this->exec('bake');
$this->assertExitCode(Shell::CODE_ERROR);
$output = $this->_out->messages();

$expected = [
'The following commands can be used to generate skeleton code for your application.',
Expand Down Expand Up @@ -226,7 +225,7 @@ public function testMain()
'By using <info>`cake bake [name]`</info> you can invoke a specific bake task.'
];

$this->assertSame($expected, $output);
$this->assertOutputContains(implode(PHP_EOL, $expected));
}

/**
Expand Down Expand Up @@ -306,10 +305,12 @@ public function testLoadTasksPlugin()
*/
public function testLoadTasksVendoredPlugin()
{
Plugin::load('Pastry/PastryTest', [
'path' => Configure::read('App.paths.plugins')[0] . 'PastryTest' . DS,
'autoload' => true
]);
$this->deprecated(function () {
Plugin::load('Pastry/PastryTest', [
'path' => Configure::read('App.paths.plugins')[0] . 'PastryTest' . DS,
'autoload' => true
]);
});

$this->Shell->loadTasks();
$this->assertContains('Pastry/PastryTest.ApplePie', $this->Shell->tasks);
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Shell/Task/BakeTemplateTaskTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function tearDown()
{
parent::tearDown();
unset($this->Task);
Plugin::unload('TestBakeTheme');
$this->removePlugins(['TestBakeTheme']);
}

/**
Expand Down
18 changes: 11 additions & 7 deletions tests/TestCase/Shell/Task/ControllerTaskTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ class ControllerTaskTest extends TestCase
* @var array
*/
public $fixtures = [
'plugin.bake.bake_articles',
'plugin.bake.bake_articles_bake_tags',
'plugin.bake.bake_comments',
'plugin.bake.bake_tags'
'plugin.Bake.BakeArticles',
'plugin.Bake.BakeArticlesBakeTags',
'plugin.Bake.BakeComments',
'plugin.Bake.BakeTags'
];

/**
Expand Down Expand Up @@ -91,8 +91,8 @@ public function tearDown()
unset($this->Task);
TableRegistry::getTableLocator()->clear();
parent::tearDown();
Plugin::unload('ControllerTest');
Plugin::unload('Company/Pastry');
$this->removePlugins(['ControllerTest']);
$this->removePlugins(['Company/Pastry']);
}

/**
Expand Down Expand Up @@ -292,7 +292,11 @@ public function testBakeTest()
$this->assertExitCode(Shell::CODE_SUCCESS);
$this->assertFilesExist($this->generatedFiles);
$this->assertFileContains(
'class BakeArticlesControllerTest extends IntegrationTestCase',
'class BakeArticlesControllerTest extends TestCase',
$this->generatedFiles[1]
);
$this->assertFileContains(
'use IntegrationTestTrait',
$this->generatedFiles[1]
);
}
Expand Down
16 changes: 9 additions & 7 deletions tests/TestCase/Shell/Task/FixtureTaskTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ class FixtureTaskTest extends TestCase
* @var array
*/
public $fixtures = [
'core.articles',
'core.comments',
'plugin.bake.datatypes',
'plugin.bake.binary_tests',
'plugin.bake.bake_car',
'core.users'
'core.Articles',
'core.Comments',
'plugin.Bake.Datatypes',
'plugin.Bake.BinaryTests',
'plugin.Bake.BakeCar',
'core.Users'
];

/**
Expand Down Expand Up @@ -196,7 +196,9 @@ public function testMainWithSingularTable()
*/
public function testMainWithPluginModel()
{
Plugin::load('FixtureTest', ['path' => APP . 'Plugin/FixtureTest/']);
$this->deprecated(function () {
Plugin::load('FixtureTest', ['path' => APP . 'Plugin/FixtureTest/']);
});

$this->generatedFile = APP . 'Plugin/FixtureTest/tests/Fixture/ArticlesFixture.php';
$this->exec('bake fixture --connection test FixtureTest.Articles');
Expand Down
10 changes: 5 additions & 5 deletions tests/TestCase/Shell/Task/ModelTaskAssociationDetectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ class ModelTaskAssociationDetectionTest extends TestCase
* @var array
*/
public $fixtures = [
'plugin.bake.categories',
'plugin.bake.categories_products',
'plugin.bake.old_products',
'plugin.bake.products',
'plugin.bake.product_versions',
'plugin.Bake.Categories',
'plugin.Bake.CategoriesProducts',
'plugin.Bake.OldProducts',
'plugin.Bake.Products',
'plugin.Bake.ProductVersions',
];

/**
Expand Down
26 changes: 13 additions & 13 deletions tests/TestCase/Shell/Task/ModelTaskTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,19 @@ class ModelTaskTest extends TestCase
* @var array
*/
public $fixtures = [
'core.users',
'core.counter_cache_users',
'core.counter_cache_posts',
'core.comments',
'core.tags',
'core.articles_tags',
'plugin.bake.bake_articles',
'plugin.bake.bake_comments',
'plugin.bake.bake_articles_bake_tags',
'plugin.bake.bake_tags',
'plugin.bake.category_threads',
'plugin.bake.invitations',
'plugin.bake.number_trees',
'core.Users',
'core.CounterCacheUsers',
'core.CounterCachePosts',
'core.Comments',
'core.Tags',
'core.ArticlesTags',
'plugin.Bake.BakeArticles',
'plugin.Bake.BakeComments',
'plugin.Bake.BakeArticlesBakeTags',
'plugin.Bake.BakeTags',
'plugin.Bake.CategoryThreads',
'plugin.Bake.Invitations',
'plugin.Bake.NumberTrees',
];

/**
Expand Down
26 changes: 14 additions & 12 deletions tests/TestCase/Shell/Task/TemplateTaskTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@ class TemplateTaskTest extends TestCase
* @var array
*/
public $fixtures = [
'core.articles',
'core.tags',
'core.articles_tags',
'core.posts',
'core.comments',
'core.test_plugin_comments',
'plugin.bake.bake_template_authors',
'plugin.bake.bake_template_roles',
'plugin.bake.bake_template_profiles',
'plugin.bake.category_threads',
'core.Articles',
'core.Tags',
'core.ArticlesTags',
'core.Posts',
'core.Comments',
'core.TestPluginComments',
'plugin.Bake.BakeTemplateAuthors',
'plugin.Bake.BakeTemplateRoles',
'plugin.Bake.BakeTemplateProfiles',
'plugin.Bake.CategoryThreads',
];

/**
Expand Down Expand Up @@ -263,7 +263,9 @@ public function testGetPathPlugin()
$this->Task->controllerName = 'Posts';

$pluginPath = APP . 'Plugin/TestTemplate/';
Plugin::load('TestTemplate', ['path' => $pluginPath]);
$this->deprecated(function () use ($pluginPath) {
Plugin::load('TestTemplate', ['path' => $pluginPath]);
});

$this->Task->params['plugin'] = $this->Task->plugin = 'TestTemplate';
$result = $this->Task->getPath();
Expand All @@ -273,7 +275,7 @@ public function testGetPathPlugin()
$result = $this->Task->getPath();
$this->assertPathEquals($pluginPath . 'src/Template/Admin/Posts/', $result);

Plugin::unload('TestTemplate');
$this->removePlugins(['TestTemplate']);
}

/**
Expand Down
36 changes: 21 additions & 15 deletions tests/TestCase/Shell/Task/TestTaskTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ class TestTaskTest extends TestCase
* @var string
*/
public $fixtures = [
'core.articles',
'core.tags',
'core.articles_tags',
'core.authors',
'core.comments',
'core.Articles',
'core.Tags',
'core.ArticlesTags',
'core.Authors',
'core.Comments',
];

/**
Expand Down Expand Up @@ -257,7 +257,9 @@ public function testOutputClassOptionsForTable()
*/
public function testOutputClassOptionsForTablePlugin()
{
Plugin::load('BakeTest');
$this->deprecated(function () {
Plugin::load('BakeTest');
});
$this->Task->plugin = 'BakeTest';

$expected = [
Expand Down Expand Up @@ -294,10 +296,10 @@ public function testFixtureArrayGenerationFromModel()
$subject = new ArticlesTable();
$result = $this->Task->generateFixtureList($subject);
$expected = [
'app.articles',
'app.authors',
'app.tags',
'app.articles_tags'
'app.Articles',
'app.Authors',
'app.Tags',
'app.ArticlesTags'
];
$this->assertEquals($expected, $result);
}
Expand All @@ -313,7 +315,7 @@ public function testFixtureArrayGenerationIgnoreSelfAssociation()
$subject = new CategoryThreadsTable();
$result = $this->Task->generateFixtureList($subject);
$expected = [
'app.category_threads',
'app.CategoryThreads',
];
$this->assertEquals($expected, $result);
}
Expand All @@ -328,7 +330,7 @@ public function testFixtureGenerationFromController()
$subject = new PostsController(new Request(), new Response());
$result = $this->Task->generateFixtureList($subject);
$expected = [
'app.posts',
'app.Posts',
];
$this->assertEquals($expected, $result);
}
Expand Down Expand Up @@ -426,7 +428,7 @@ public function testBakeFixturesParam()
->method('createFile')
->will($this->returnValue(true));

$this->Task->params['fixtures'] = 'app.posts, app.comments , app.users ,';
$this->Task->params['fixtures'] = 'app.Posts, app.Comments, app.Users,';
$result = $this->Task->bake('Table', 'Articles');
$this->assertSameAsFile(__FUNCTION__ . '.php', $result);
}
Expand Down Expand Up @@ -756,7 +758,9 @@ public function testBakeWithPlugin()
{
$this->Task->plugin = 'TestTest';

Plugin::load('TestTest', ['path' => APP . 'Plugin' . DS . 'TestTest' . DS]);
$this->deprecated(function () {
Plugin::load('TestTest', ['path' => APP . 'Plugin' . DS . 'TestTest' . DS]);
});
$path = APP . 'Plugin/TestTest/tests/TestCase/View/Helper/FormHelperTest.php';
$path = str_replace('/', DS, $path);
$this->Task->expects($this->once())->method('createFile')
Expand Down Expand Up @@ -820,7 +824,9 @@ public function testTestCaseFileNamePlugin()
{
$this->Task->path = DS . 'my/path/tests/';

Plugin::load('TestTest', ['path' => APP . 'Plugin' . DS . 'TestTest' . DS]);
$this->deprecated(function () {
Plugin::load('TestTest', ['path' => APP . 'Plugin' . DS . 'TestTest' . DS]);
});
$this->Task->plugin = 'TestTest';
$class = 'TestBake\Model\Entity\Post';
$result = $this->Task->testCaseFileName('entity', $class);
Expand Down
Loading

0 comments on commit 336a97f

Please sign in to comment.