Skip to content
Permalink
Browse files

Add stub helper

  • Loading branch information...
dereuromark committed Sep 22, 2014
1 parent 65c2311 commit 0a324ec9ded25947ca5022dccc6be670b8a758b6
@@ -15,6 +15,7 @@
namespace Cake\Test\TestCase\View;
use Cake\Core\App;
use Cake\Core\Configure;
use Cake\Core\Plugin;
use Cake\TestSuite\TestCase;
use Cake\View\Helper;
@@ -187,20 +188,20 @@ public function testLoadPluginHelper() {
* @return void
*/
public function testReset() {
$this->skipIf(true, 'Currently no helper with any event');
Configure::write('App.namespace', 'TestApp');
$instance = $this->Helpers->load('Paginator');
$instance = $this->Helpers->load('EventListenerTest');
$this->assertSame(
$instance,
$this->Helpers->Paginator,
$this->Helpers->EventListenerTest,
'Instance in registry should be the same as previously loaded'
);
$this->assertCount(1, $this->Events->listeners('View.beforeRender'));
$this->assertNull($this->Helpers->reset(), 'No return expected');
$this->assertCount(0, $this->Events->listeners('View.beforeRender'));
$this->assertNotSame($instance, $this->Helpers->load('Paginator'));
$this->assertNotSame($instance, $this->Helpers->load('EventListenerTest'));
}
/**
@@ -209,17 +210,18 @@ public function testReset() {
* @return void
*/
public function testUnload() {
$this->skipIf(true, 'Currently no helper with any event');
Configure::write('App.namespace', 'TestApp');
$instance = $this->Helpers->load('Paginator');
$instance = $this->Helpers->load('EventListenerTest');
$this->assertSame(
$instance,
$this->Helpers->Paginator,
$this->Helpers->EventListenerTest,
'Instance in registry should be the same as previously loaded'
);
$this->assertCount(1, $this->Events->listeners('View.beforeRender'));
$this->assertNull($this->Helpers->unload('Paginator'), 'No return expected');
$this->assertNull($this->Helpers->unload('EventListenerTest'), 'No return expected');
$this->assertCount(0, $this->Events->listeners('View.beforeRender'));
}
}
@@ -0,0 +1,42 @@
<?php
/**
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project
* @since 3.0.0
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
namespace TestApp\View\Helper;
use Cake\Event\Event;
use Cake\View\Helper;
class EventListenerTestHelper extends Helper {
/**
* Before render callback. Stub.
*
* @param \Cake\Event\Event $event The event instance.
* @param string $viewFile The view file being rendered.
* @return void
*/
public function beforeRender(Event $event, $viewFile) {
$this->config('options.foo', 'bar');
}
/**
* Event listeners.
*
* @return array
*/
public function implementedEvents() {
return ['View.beforeRender' => 'beforeRender'];
}
}

0 comments on commit 0a324ec

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