Skip to content

Commit

Permalink
Fix usage of config() in database, orm, view tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Nov 11, 2017
1 parent 253f47a commit 14cb9dc
Show file tree
Hide file tree
Showing 15 changed files with 33 additions and 33 deletions.
2 changes: 1 addition & 1 deletion tests/TestCase/Database/Driver/MysqlTest.php
Expand Up @@ -32,7 +32,7 @@ class MysqlTest extends TestCase
public function setup()
{
parent::setUp();
$config = ConnectionManager::config('test');
$config = ConnectionManager::getConfig('test');
$this->skipIf(strpos($config['driver'], 'Mysql') === false, 'Not using Mysql for test config');
}

Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Database/Schema/MysqlSchemaTest.php
Expand Up @@ -35,7 +35,7 @@ class MysqlSchemaTest extends TestCase
*/
protected function _needsConnection()
{
$config = ConnectionManager::config('test');
$config = ConnectionManager::getConfig('test');
$this->skipIf(strpos($config['driver'], 'Mysql') === false, 'Not using Mysql for test config');
}

Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Database/Schema/PostgresSchemaTest.php
Expand Up @@ -35,7 +35,7 @@ class PostgresSchemaTest extends TestCase
*/
protected function _needsConnection()
{
$config = ConnectionManager::config('test');
$config = ConnectionManager::getConfig('test');
$this->skipIf(strpos($config['driver'], 'Postgres') === false, 'Not using Postgres for test config');
}

Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Database/Schema/SqliteSchemaTest.php
Expand Up @@ -35,7 +35,7 @@ class SqliteSchemaTest extends TestCase
*/
protected function _needsConnection()
{
$config = ConnectionManager::config('test');
$config = ConnectionManager::getConfig('test');
$this->skipIf(strpos($config['driver'], 'Sqlite') === false, 'Not using Sqlite for test config');
}

Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Database/Schema/SqlserverSchemaTest.php
Expand Up @@ -34,7 +34,7 @@ class SqlserverSchemaTest extends TestCase
*/
protected function _needsConnection()
{
$config = ConnectionManager::config('test');
$config = ConnectionManager::getConfig('test');
$this->skipIf(strpos($config['driver'], 'Sqlserver') === false, 'Not using Sqlserver for test config');
}

Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/ORM/Association/BelongsToManyTest.php
Expand Up @@ -189,7 +189,7 @@ public function testJunctionConnection()
->setMethods(['setDriver'])
->setConstructorArgs(['name' => 'other_source'])
->getMock();
ConnectionManager::config('other_source', $mock);
ConnectionManager::setConfig('other_source', $mock);
$this->article->connection(ConnectionManager::get('other_source'));

$assoc = new BelongsToMany('Test', [
Expand Down
8 changes: 4 additions & 4 deletions tests/TestCase/ORM/Behavior/TreeBehaviorTest.php
Expand Up @@ -667,7 +667,7 @@ public function testRecover()
->order('lft')
->toArray();
$table->updateAll(['lft' => null, 'rght' => null, 'depth' => null], []);
$table->behaviors()->Tree->config('level', 'depth');
$table->behaviors()->Tree->setConfig('level', 'depth');
$table->recover();

$expected = [
Expand Down Expand Up @@ -1223,7 +1223,7 @@ public function testDeleteSubTreeScopedTree()
];
$this->assertMpttValues($expected, $table);

$table->behaviors()->get('Tree')->config('scope', ['menu' => 'categories']);
$table->behaviors()->get('Tree')->setConfig('scope', ['menu' => 'categories']);
$expected = [
' 1:10 - 9:electronics',
'_ 2: 9 - 10:televisions',
Expand Down Expand Up @@ -1418,7 +1418,7 @@ public function testGetLevel()
*/
public function testSetLevelNewNode()
{
$this->table->behaviors()->Tree->config('level', 'depth');
$this->table->behaviors()->Tree->setConfig('level', 'depth');

$entity = new Entity(['parent_id' => null, 'name' => 'Depth 0']);
$this->table->save($entity);
Expand All @@ -1443,7 +1443,7 @@ public function testSetLevelNewNode()
*/
public function testSetLevelExistingNode()
{
$this->table->behaviors()->Tree->config('level', 'depth');
$this->table->behaviors()->Tree->setConfig('level', 'depth');

// Leaf node
$entity = $this->table->get(4);
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/ORM/BehaviorRegistryTest.php
Expand Up @@ -62,7 +62,7 @@ public function testLoad()
$config = ['alias' => 'Sluggable', 'replacement' => '-'];
$result = $this->Behaviors->load('Sluggable', $config);
$this->assertInstanceOf('TestApp\Model\Behavior\SluggableBehavior', $result);
$this->assertEquals($config, $result->config());
$this->assertEquals($config, $result->getConfig());

$result = $this->Behaviors->load('TestPlugin.PersisterOne');
$this->assertInstanceOf('TestPlugin\Model\Behavior\PersisterOneBehavior', $result);
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/ORM/BehaviorTest.php
Expand Up @@ -193,7 +193,7 @@ public function testConstructor()
$table = $this->getMockBuilder('Cake\ORM\Table')->getMock();
$config = ['key' => 'value'];
$behavior = new TestBehavior($table, $config);
$this->assertEquals($config, $behavior->config());
$this->assertEquals($config, $behavior->getConfig());
}

/**
Expand Down
6 changes: 3 additions & 3 deletions tests/TestCase/ORM/TableTest.php
Expand Up @@ -2586,7 +2586,7 @@ public function testSaveNewErrorOnNoPrimaryKey()
*/
public function testAtomicSave()
{
$config = ConnectionManager::config('test');
$config = ConnectionManager::getConfig('test');

$connection = $this->getMockBuilder('\Cake\Database\Connection')
->setMethods(['begin', 'commit', 'inTransaction'])
Expand Down Expand Up @@ -2623,7 +2623,7 @@ public function testAtomicSaveRollback()
{
$connection = $this->getMockBuilder('\Cake\Database\Connection')
->setMethods(['begin', 'rollback'])
->setConstructorArgs([ConnectionManager::config('test')])
->setConstructorArgs([ConnectionManager::getConfig('test')])
->getMock();
$connection->setDriver(ConnectionManager::get('test')->getDriver());
$table = $this->getMockBuilder('\Cake\ORM\Table')
Expand Down Expand Up @@ -2663,7 +2663,7 @@ public function testAtomicSaveRollbackOnFailure()
{
$connection = $this->getMockBuilder('\Cake\Database\Connection')
->setMethods(['begin', 'rollback'])
->setConstructorArgs([ConnectionManager::config('test')])
->setConstructorArgs([ConnectionManager::getConfig('test')])
->getMock();
$connection->setDriver(ConnectionManager::get('test')->getDriver());
$table = $this->getMockBuilder('\Cake\ORM\Table')
Expand Down
12 changes: 6 additions & 6 deletions tests/TestCase/View/CellTest.php
Expand Up @@ -403,7 +403,7 @@ public function testCachedRenderSimple()
$mock->expects($this->once())
->method('write')
->with('cell_test_app_view_cell_articles_cell_display_default', "dummy\n");
Cache::config('default', $mock);
Cache::setConfig('default', $mock);

$cell = $this->View->cell('Articles', [], ['cache' => true]);
$result = $cell->render();
Expand All @@ -425,7 +425,7 @@ public function testReadCachedCell()
->will($this->returnValue("dummy\n"));
$mock->expects($this->never())
->method('write');
Cache::config('default', $mock);
Cache::setConfig('default', $mock);

$cell = $this->View->cell('Articles', [], ['cache' => true]);
$result = $cell->render();
Expand All @@ -448,7 +448,7 @@ public function testCachedRenderArrayConfig()
$mock->expects($this->once())
->method('write')
->with('my_key', "dummy\n");
Cache::config('cell', $mock);
Cache::setConfig('cell', $mock);

$cell = $this->View->cell('Articles', [], [
'cache' => ['key' => 'my_key', 'config' => 'cell']
Expand All @@ -473,7 +473,7 @@ public function testCachedRenderSimpleCustomTemplate()
$mock->expects($this->once())
->method('write')
->with('cell_test_app_view_cell_articles_cell_customTemplate_default', "<h1>This is the alternate template</h1>\n");
Cache::config('default', $mock);
Cache::setConfig('default', $mock);

$cell = $this->View->cell('Articles::customTemplate', [], ['cache' => true]);
$result = $cell->render();
Expand All @@ -490,7 +490,7 @@ public function testCachedRenderSimpleCustomTemplate()
*/
public function testCachedRenderSimpleCustomTemplateViewBuilder()
{
Cache::config('default', [
Cache::setConfig('default', [
'className' => 'File',
'path' => CACHE,
]);
Expand All @@ -512,7 +512,7 @@ public function testCachedRenderSimpleCustomTemplateViewBuilder()
*/
public function testACachedViewCellReRendersWhenGivenADifferentTemplate()
{
Cache::config('default', [
Cache::setConfig('default', [
'className' => 'File',
'path' => CACHE,
]);
Expand Down
10 changes: 5 additions & 5 deletions tests/TestCase/View/Helper/TimeHelperTest.php
Expand Up @@ -178,7 +178,7 @@ public function testNice()
*/
public function testNiceOutputTimezone()
{
$this->Time->config('outputTimezone', 'America/Vancouver');
$this->Time->setConfig('outputTimezone', 'America/Vancouver');
$time = '2014-04-20 20:00';
$this->assertTimeFormat('Apr 20, 2014, 1:00 PM', $this->Time->nice($time));
}
Expand Down Expand Up @@ -211,7 +211,7 @@ public function testToAtom()
*/
public function testToAtomOutputTimezone()
{
$this->Time->config('outputTimezone', 'America/Vancouver');
$this->Time->setConfig('outputTimezone', 'America/Vancouver');
$dateTime = new Time;
$vancouver = clone $dateTime;
$vancouver->timezone('America/Vancouver');
Expand Down Expand Up @@ -245,7 +245,7 @@ public function testToRss()
*/
public function testToRssOutputTimezone()
{
$this->Time->config('outputTimezone', 'America/Vancouver');
$this->Time->setConfig('outputTimezone', 'America/Vancouver');
$dateTime = new Time;
$vancouver = clone $dateTime;
$vancouver->timezone('America/Vancouver');
Expand Down Expand Up @@ -548,7 +548,7 @@ public function testFormat()
*/
public function testFormatOutputTimezone()
{
$this->Time->config('outputTimezone', 'America/Vancouver');
$this->Time->setConfig('outputTimezone', 'America/Vancouver');

$time = strtotime('Thu Jan 14 8:59:28 2010 UTC');
$result = $this->Time->format($time);
Expand All @@ -568,7 +568,7 @@ public function testFormatOutputTimezone()
*/
public function testI18nFormatOutputTimezone()
{
$this->Time->config('outputTimezone', 'America/Vancouver');
$this->Time->setConfig('outputTimezone', 'America/Vancouver');

$time = strtotime('Thu Jan 14 8:59:28 2010 UTC');
$result = $this->Time->i18nFormat($time, \IntlDateFormatter::SHORT);
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/View/HelperTest.php
Expand Up @@ -98,7 +98,7 @@ public function testSettingsMerging()
'key2' => ['key2.1' => 'val2.1', 'key2.2' => 'newval'],
'key3' => 'val3'
];
$this->assertEquals($expected, $Helper->config());
$this->assertEquals($expected, $Helper->getConfig());
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/View/StringTemplateTraitTest.php
Expand Up @@ -85,7 +85,7 @@ public function testInitStringTemplates()
*/
public function testInitStringTemplatesArrayForm()
{
$this->Template->config(
$this->Template->setConfig(
'templates.text',
'<p>{{text}}</p>'
);
Expand Down
10 changes: 5 additions & 5 deletions tests/TestCase/View/ViewTest.php
Expand Up @@ -989,7 +989,7 @@ public function testElementCacheHelperNoCache()
public function testElementCache()
{
Cache::drop('test_view');
Cache::config('test_view', [
Cache::setConfig('test_view', [
'engine' => 'File',
'duration' => '+1 day',
'path' => CACHE . 'views/',
Expand Down Expand Up @@ -1074,7 +1074,7 @@ public function testLoadHelper()
$View->loadHelper('Html', ['foo' => 'bar']);
$this->assertInstanceOf('Cake\View\Helper\HtmlHelper', $View->Html);

$config = $View->Html->config();
$config = $View->Html->getConfig();
$this->assertEquals('bar', $config['foo']);
}

Expand Down Expand Up @@ -1112,10 +1112,10 @@ public function testLoadHelpers()
$this->assertInstanceOf('Cake\View\Helper\HtmlHelper', $View->Html, 'Object type is wrong.');
$this->assertInstanceOf('Cake\View\Helper\FormHelper', $View->Form, 'Object type is wrong.');

$config = $View->Html->config();
$config = $View->Html->getConfig();
$this->assertEquals('bar', $config['foo']);

$config = $View->Form->config();
$config = $View->Form->getConfig();
$this->assertEquals('baz', $config['foo']);
}

Expand All @@ -1141,7 +1141,7 @@ public function testLazyLoadHelpers()
public function testInitialize()
{
$View = new TestView();
$config = $View->Html->config();
$config = $View->Html->getConfig();
$this->assertEquals('myval', $config['mykey']);
}

Expand Down

0 comments on commit 14cb9dc

Please sign in to comment.