Skip to content
Permalink
Browse files

adding tests for engine overrides

  • Loading branch information...
rchavik committed Feb 14, 2012
1 parent 369d316 commit fe479c636c698f8868d8061af87f20a621410fdb
@@ -29,6 +29,10 @@ public function attach(CakeNumberMock $cakeNumber) {
$this->_CakeNumber = $cakeNumber;
}
public function engine() {
return $this->_CakeNumber;
}
}
/**
@@ -82,4 +86,23 @@ public function testNumberHelperProxyMethodCalls() {
}
}
/**
* test engine override
*/
public function testEngineOverride() {
App::build(array(
'Utility' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Utility' . DS)
), APP::REGISTER);
$Number = new NumberHelperTestObject($this->View, array('engine' => 'TestAppEngine'));
$this->assertInstanceOf('TestAppEngine', $Number->engine());
App::build(array(
'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS)
));
CakePlugin::load('TestPlugin');
$Number = new NumberHelperTestObject($this->View, array('engine' => 'TestPlugin.TestPluginEngine'));
$this->assertInstanceOf('TestPluginEngine', $Number->engine());
CakePlugin::unload('TestPlugin');
}
}
@@ -26,6 +26,10 @@ public function attach(StringMock $string) {
$this->_String = $string;
}
public function engine() {
return $this->_String;
}
}
/**
@@ -78,6 +82,25 @@ public function testTextHelperProxyMethodCalls() {
}
}
/**
* test engine override
*/
public function testEngineOverride() {
App::build(array(
'Utility' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Utility' . DS)
), APP::REGISTER);
$Text = new TextHelperTestObject($this->View, array('engine' => 'TestAppEngine'));
$this->assertInstanceOf('TestAppEngine', $Text->engine());
App::build(array(
'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS)
));
CakePlugin::load('TestPlugin');
$Text = new TextHelperTestObject($this->View, array('engine' => 'TestPlugin.TestPluginEngine'));
$this->assertInstanceOf('TestPluginEngine', $Text->engine());
CakePlugin::unload('TestPlugin');
}
/**
* testAutoLink method
*
@@ -29,6 +29,10 @@ public function attach(CakeTimeMock $cakeTime) {
$this->_CakeTime = $cakeTime;
}
public function engine() {
return $this->_CakeTime;
}
}
/**
@@ -88,4 +92,23 @@ public function testTimeHelperProxyMethodCalls() {
}
}
/**
* test engine override
*/
public function testEngineOverride() {
App::build(array(
'Utility' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Utility' . DS)
), APP::REGISTER);
$Time = new TimeHelperTestObject($this->View, array('engine' => 'TestAppEngine'));
$this->assertInstanceOf('TestAppEngine', $Time->engine());
App::build(array(
'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS)
));
CakePlugin::load('TestPlugin');
$Time = new TimeHelperTestObject($this->View, array('engine' => 'TestPlugin.TestPluginEngine'));
$this->assertInstanceOf('TestPluginEngine', $Time->engine());
CakePlugin::unload('TestPlugin');
}
}
@@ -0,0 +1,5 @@
<?php
class TestPluginEngine {
}
@@ -0,0 +1,5 @@
<?php
class TestAppEngine {
}
@@ -45,8 +45,8 @@ class NumberHelper extends AppHelper {
function __construct(View $View, $settings = array()) {
$settings = Set::merge(array('engine' => 'CakeNumber'), $settings);
parent::__construct($View, $settings);
$engineClass = $settings['engine'];
App::uses($engineClass, 'Utility');
list($plugin, $engineClass) = pluginSplit($settings['engine'], true);
App::uses($engineClass, $plugin . 'Utility');
if (class_exists($engineClass)) {
$this->_CakeNumber = new $engineClass($settings);
} else {
@@ -62,8 +62,8 @@ class TextHelper extends AppHelper {
public function __construct(View $View, $settings = array()) {
$settings = Set::merge(array('engine' => 'String'), $settings);
parent::__construct($View, $settings);
$engineClass = $settings['engine'];
App::uses($engineClass, 'Utility');
list($plugin, $engineClass) = pluginSplit($settings['engine'], true);
App::uses($engineClass, $plugin . 'Utility');
if (class_exists($engineClass)) {
$this->_String = new $engineClass($settings);
} else {
@@ -46,8 +46,8 @@ class TimeHelper extends AppHelper {
public function __construct(View $View, $settings = array()) {
$settings = Set::merge(array('engine' => 'CakeTime'), $settings);
parent::__construct($View, $settings);
$engineClass = $settings['engine'];
App::uses($engineClass, 'Utility');
list($plugin, $engineClass) = pluginSplit($settings['engine'], true);
App::uses($engineClass, $plugin . 'Utility');
if (class_exists($engineClass)) {
$this->_CakeTime = new $engineClass($settings);
} else {

0 comments on commit fe479c6

Please sign in to comment.
You can’t perform that action at this time.