mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-03-15 05:59:50 +00:00
Fixing a few failing tests in helper tests.
This commit is contained in:
parent
122dc65427
commit
f87ae5469b
7 changed files with 24 additions and 18 deletions
|
@ -474,10 +474,11 @@ abstract class JsBaseEngineHelper extends AppHelper {
|
|||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @return void
|
||||
* @param View $View The View this helper is attached to.
|
||||
* @param array $settings An array of settings.
|
||||
*/
|
||||
function __construct() {
|
||||
parent::__construct();
|
||||
function __construct($View, $settings = array()) {
|
||||
parent::__construct($View, $settings);
|
||||
$this->useNative = function_exists('json_encode');
|
||||
}
|
||||
|
||||
|
|
|
@ -254,9 +254,9 @@ class TimeHelper extends AppHelper {
|
|||
$y = $this->isThisYear($date) ? '' : ' %Y';
|
||||
|
||||
if ($this->isToday($dateString, $userOffset)) {
|
||||
$ret = sprintf(__('Today, %s', strftime("%H:%M", $date));
|
||||
$ret = __('Today, %s', strftime("%H:%M", $date));
|
||||
} elseif ($this->wasYesterday($dateString, $userOffset)) {
|
||||
$ret = sprintf(__('Yesterday, %s', strftime("%H:%M", $date));
|
||||
$ret = __('Yesterday, %s', strftime("%H:%M", $date));
|
||||
} else {
|
||||
$format = $this->convertSpecifiers("%b %eS{$y}, %H:%M", $date);
|
||||
$ret = strftime($format, $date);
|
||||
|
|
|
@ -30,8 +30,8 @@ class JqueryEngineHelperTest extends CakeTestCase {
|
|||
function setUp() {
|
||||
parent::setUp();
|
||||
$controller = null;
|
||||
$View = new View($controller);
|
||||
$this->Jquery = new JqueryEngineHelper($View);
|
||||
$this->View = $this->getMock('View', array('addScript'), array(&$controller));
|
||||
$this->Jquery = new JqueryEngineHelper($this->View);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -102,9 +102,7 @@ class JsHelperTest extends CakeTestCase {
|
|||
|
||||
$this->Js->Form->request = $request;
|
||||
$this->Js->Form->Html = $this->Js->Html;
|
||||
$this->Js->OptionEngine = new OptionEngineHelper();
|
||||
|
||||
ClassRegistry::addObject('view', $this->View);
|
||||
$this->Js->OptionEngine = new OptionEngineHelper($this->View);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -115,7 +113,6 @@ class JsHelperTest extends CakeTestCase {
|
|||
*/
|
||||
function tearDown() {
|
||||
Configure::write('Asset.timestamp', $this->_asset);
|
||||
ClassRegistry::removeObject('view');
|
||||
unset($this->Js);
|
||||
}
|
||||
|
||||
|
@ -128,7 +125,7 @@ class JsHelperTest extends CakeTestCase {
|
|||
$request = new CakeRequest(null, false);
|
||||
|
||||
if (!class_exists('TestJsEngineHelper', false)) {
|
||||
$this->getMock('JsBaseEngineHelper', array(), array(), 'TestJsEngineHelper');
|
||||
$this->getMock('JsBaseEngineHelper', array(), array($this->View), 'TestJsEngineHelper');
|
||||
}
|
||||
|
||||
$this->Js = new JsHelper($this->View, array('TestJs'));
|
||||
|
@ -312,7 +309,7 @@ class JsHelperTest extends CakeTestCase {
|
|||
return;
|
||||
}
|
||||
$this->Js->request->webroot = '/';
|
||||
$this->Js->JsBaseEngine = new TestJsEngineHelper();
|
||||
$this->Js->JsBaseEngine = new TestJsEngineHelper($this->View);
|
||||
$this->Js->buffer('one = 1;');
|
||||
$this->Js->buffer('two = 2;');
|
||||
$result = $this->Js->writeBuffer(array('onDomReady' => false, 'cache' => true));
|
||||
|
@ -690,7 +687,7 @@ class JsBaseEngineTest extends CakeTestCase {
|
|||
function setUp() {
|
||||
parent::setUp();
|
||||
$controller = null;
|
||||
$this->View = new View($controller);
|
||||
$this->View = $this->getMock('View', array('addScript'), array(&$controller));
|
||||
$this->JsEngine = new OptionEngineHelper($this->View);
|
||||
}
|
||||
/**
|
||||
|
@ -911,7 +908,7 @@ class JsBaseEngineTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
function testOptionMapping() {
|
||||
$JsEngine = new OptionEngineHelper();
|
||||
$JsEngine = new OptionEngineHelper($this->View);
|
||||
$result = $JsEngine->testMap();
|
||||
$this->assertEqual($result, array());
|
||||
|
||||
|
@ -931,7 +928,7 @@ class JsBaseEngineTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
function testOptionParsing() {
|
||||
$JsEngine = new OptionEngineHelper();
|
||||
$JsEngine = new OptionEngineHelper($this->View);
|
||||
|
||||
$result = $JsEngine->testParseOptions(array('url' => '/posts/view/1', 'key' => 1));
|
||||
$expected = 'key:1, url:"\\/posts\\/view\\/1"';
|
||||
|
|
|
@ -30,7 +30,9 @@ class MooEngineHelperTest extends CakeTestCase {
|
|||
*/
|
||||
function setUp() {
|
||||
parent::setUp();
|
||||
$this->Moo = new MootoolsEngineHelper();
|
||||
$controller = null;
|
||||
$this->View = $this->getMock('View', array('addScript'), array(&$controller));
|
||||
$this->Moo = new MootoolsEngineHelper($this->View);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -28,7 +28,9 @@ class PrototypeEngineHelperTest extends CakeTestCase {
|
|||
*/
|
||||
function setUp() {
|
||||
parent::setUp();
|
||||
$this->Proto = new PrototypeEngineHelper();
|
||||
$controller = null;
|
||||
$this->View = $this->getMock('View', array('addScript'), array(&$controller));
|
||||
$this->Proto = new PrototypeEngineHelper($this->View);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -38,6 +38,10 @@ class SessionHelperTest extends CakeTestCase {
|
|||
$this->View = new View($controller);
|
||||
$this->Session = new SessionHelper($this->View);
|
||||
|
||||
if (!CakeSession::started()) {
|
||||
CakeSession::start();
|
||||
}
|
||||
|
||||
$_SESSION = array(
|
||||
'test' => 'info',
|
||||
'Message' => array(
|
||||
|
|
Loading…
Add table
Reference in a new issue