Skip to content

Commit

Permalink
Replace other literal configure calls with new convenience function s…
Browse files Browse the repository at this point in the history
…etAppNamespace()
  • Loading branch information
ravage84 committed Jun 15, 2017
1 parent 3caa498 commit 4167141
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 20 deletions.
3 changes: 1 addition & 2 deletions tests/TestCase/Core/AppTest.php
Expand Up @@ -14,7 +14,6 @@
namespace Cake\Test\TestCase\Core;

use Cake\Core\App;
use Cake\Core\Configure;
use Cake\Core\Plugin;
use Cake\TestSuite\TestCase;
use TestApp\Core\TestApp;
Expand Down Expand Up @@ -93,7 +92,7 @@ public function testShortName($class, $type, $suffix = '', $expected = false)
*/
public function testShortNameWithNestedAppNamespace()
{
Configure::write('App.namespace', 'TestApp/Nested');
static::setAppNamespace('TestApp/Nested');

$return = TestApp::shortName(
'TestApp/Nested/Controller/PagesController',
Expand Down
3 changes: 1 addition & 2 deletions tests/TestCase/Http/MiddlewareQueueTest.php
Expand Up @@ -46,8 +46,7 @@ public function setUp()
public function tearDown()
{
parent::tearDown();

Configure::write('App.namespace', $this->appNamespace);
static::setAppNamespace($this->appNamespace);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Mailer/MailerAwareTraitTest.php
Expand Up @@ -45,7 +45,7 @@ public function testGetMailer()
static::setAppNamespace();
$stub = new Stub();
$this->assertInstanceOf('TestApp\Mailer\TestMailer', $stub->getMailer('Test'));
Configure::write('App.namespace', $originalAppNamespace);
static::setAppNamespace($originalAppNamespace);
}

/**
Expand Down
3 changes: 1 addition & 2 deletions tests/TestCase/Shell/CompletionShellTest.php
Expand Up @@ -16,7 +16,6 @@

use Cake\Console\ConsoleIo;
use Cake\Console\ConsoleOutput;
use Cake\Core\Configure;
use Cake\Core\Plugin;
use Cake\TestSuite\TestCase;

Expand Down Expand Up @@ -74,7 +73,7 @@ public function tearDown()
{
parent::tearDown();
unset($this->Shell);
Configure::write('App.namespace', 'App');
static::setAppNamespace('App');
Plugin::unload();
}

Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/View/Helper/FormHelperTest.php
Expand Up @@ -144,7 +144,7 @@ public function setUp()

Configure::write('Config.language', 'eng');
Configure::write('App.base', '');
Configure::write('App.namespace', 'Cake\Test\TestCase\View\Helper');
static::setAppNamespace('Cake\Test\TestCase\View\Helper');
$this->View = new View();

$this->Form = new FormHelper($this->View);
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/View/Helper/NumberHelperTest.php
Expand Up @@ -74,7 +74,7 @@ public function setUp()
public function tearDown()
{
parent::tearDown();
Configure::write('App.namespace', $this->_appNamespace);
static::setAppNamespace($this->_appNamespace);
unset($this->View);
}

Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/View/Helper/TextHelperTest.php
Expand Up @@ -78,7 +78,7 @@ public function setUp()
public function tearDown()
{
unset($this->Text, $this->View);
Configure::write('App.namespace', $this->_appNamespace);
static::setAppNamespace($this->_appNamespace);
parent::tearDown();
}

Expand Down
3 changes: 1 addition & 2 deletions tests/TestCase/View/ViewBuilderTest.php
Expand Up @@ -14,7 +14,6 @@
*/
namespace Cake\Test\TestCase\View;

use Cake\Core\Configure;
use Cake\TestSuite\TestCase;
use Cake\View\ViewBuilder;

Expand Down Expand Up @@ -151,7 +150,7 @@ public function testBuildComplete()
*/
public function testBuildAppViewMissing()
{
Configure::write('App.namespace', 'Nope');
static::setAppNamespace('Nope');
$builder = new ViewBuilder();
$view = $builder->build();
$this->assertInstanceOf('Cake\View\View', $view);
Expand Down
16 changes: 8 additions & 8 deletions tests/test_app/TestApp/Shell/TestingDispatchShell.php
Expand Up @@ -17,7 +17,7 @@
namespace TestApp\Shell;

use Cake\Console\Shell;
use Cake\Core\Configure;
use Cake\TestSuite\TestCase;

/**
* for testing dispatchShell functionality
Expand All @@ -38,35 +38,35 @@ public function out($message = null, $newlines = 1, $level = Shell::NORMAL)
public function testTask()
{
$this->out('I am a test task, I dispatch another Shell');
Configure::write('App.namespace', 'TestApp');
TestCase::setAppNamespace();
$this->dispatchShell('testing_dispatch dispatch_test_task');
}

public function testTaskDispatchArray()
{
$this->out('I am a test task, I dispatch another Shell');
Configure::write('App.namespace', 'TestApp');
TestCase::setAppNamespace();
$this->dispatchShell('testing_dispatch', 'dispatch_test_task');
}

public function testTaskDispatchCommandString()
{
$this->out('I am a test task, I dispatch another Shell');
Configure::write('App.namespace', 'TestApp');
TestCase::setAppNamespace();
$this->dispatchShell(['command' => 'testing_dispatch dispatch_test_task']);
}

public function testTaskDispatchCommandArray()
{
$this->out('I am a test task, I dispatch another Shell');
Configure::write('App.namespace', 'TestApp');
TestCase::setAppNamespace();
$this->dispatchShell(['command' => ['testing_dispatch', 'dispatch_test_task']]);
}

public function testTaskDispatchWithParam()
{
$this->out('I am a test task, I dispatch another Shell');
Configure::write('App.namespace', 'TestApp');
TestCase::setAppNamespace();
$this->dispatchShell([
'command' => ['testing_dispatch', 'dispatch_test_task_param'],
'extra' => [
Expand All @@ -78,7 +78,7 @@ public function testTaskDispatchWithParam()
public function testTaskDispatchWithMultipleParams()
{
$this->out('I am a test task, I dispatch another Shell');
Configure::write('App.namespace', 'TestApp');
TestCase::setAppNamespace();
$this->dispatchShell([
'command' => 'testing_dispatch dispatch_test_task_params',
'extra' => [
Expand All @@ -91,7 +91,7 @@ public function testTaskDispatchWithMultipleParams()
public function testTaskDispatchWithRequestedOff()
{
$this->out('I am a test task, I dispatch another Shell');
Configure::write('App.namespace', 'TestApp');
TestCase::setAppNamespace();
$this->dispatchShell([
'command' => ['testing_dispatch', 'dispatch_test_task'],
'extra' => [
Expand Down

0 comments on commit 4167141

Please sign in to comment.