mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-03-17 06:59:51 +00:00
Making PaginatorHelper test run under PHPUnit.
This commit is contained in:
parent
d3837ba7b0
commit
07c957e827
1 changed files with 8 additions and 7 deletions
|
@ -19,8 +19,6 @@
|
||||||
*/
|
*/
|
||||||
App::import('Helper', array('Html', 'Paginator', 'Form', 'Js'));
|
App::import('Helper', array('Html', 'Paginator', 'Form', 'Js'));
|
||||||
|
|
||||||
Mock::generate('JsHelper', 'PaginatorMockJsHelper');
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PaginatorHelperTest class
|
* PaginatorHelperTest class
|
||||||
*
|
*
|
||||||
|
@ -58,7 +56,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$this->Paginator->Html = new HtmlHelper();
|
$this->Paginator->Html = new HtmlHelper();
|
||||||
$this->Paginator->Js = new PaginatorMockJsHelper();
|
$this->Paginator->Js = $this->getMock('PaginatorHelper');
|
||||||
|
|
||||||
Configure::write('Routing.prefixes', array());
|
Configure::write('Routing.prefixes', array());
|
||||||
Router::reload();
|
Router::reload();
|
||||||
|
@ -1851,8 +1849,10 @@ class PaginatorHelperTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function testAjaxLinkGenerationLink() {
|
function testAjaxLinkGenerationLink() {
|
||||||
$this->Paginator->Js->expectCallCount('link', 1);
|
$this->Paginator->Js->expects($this->once())
|
||||||
$this->Paginator->Js->setReturnValue('link', 'I am a link');
|
->method('link')
|
||||||
|
->will($this->returnValue('I am a link'));
|
||||||
|
|
||||||
$result = $this->Paginator->link('test', array('controller' => 'posts'), array('update' => '#content'));
|
$result = $this->Paginator->link('test', array('controller' => 'posts'), array('update' => '#content'));
|
||||||
$this->assertEqual($result, 'I am a link');
|
$this->assertEqual($result, 'I am a link');
|
||||||
}
|
}
|
||||||
|
@ -1863,6 +1863,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function testMockAjaxProviderClassInjection() {
|
function testMockAjaxProviderClassInjection() {
|
||||||
|
$mock = $this->getMock('PaginatorHelper', array(), array(), 'PaginatorMockJsHelper');
|
||||||
$Paginator = new PaginatorHelper(array('ajax' => 'PaginatorMockJs'));
|
$Paginator = new PaginatorHelper(array('ajax' => 'PaginatorMockJs'));
|
||||||
$Paginator->params['paging'] = array(
|
$Paginator->params['paging'] = array(
|
||||||
'Article' => array(
|
'Article' => array(
|
||||||
|
@ -1875,8 +1876,8 @@ class PaginatorHelperTest extends CakeTestCase {
|
||||||
'options' => array()
|
'options' => array()
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$Paginator->PaginatorMockJs = new PaginatorMockJsHelper();
|
$Paginator->PaginatorMockJs = $mock;
|
||||||
$Paginator->PaginatorMockJs->expectOnce('link');
|
$Paginator->PaginatorMockJs->expects($this->once())->method('link');
|
||||||
$result = $Paginator->link('Page 2', array('page' => 2), array('update' => '#content'));
|
$result = $Paginator->link('Page 2', array('page' => 2), array('update' => '#content'));
|
||||||
|
|
||||||
$this->expectException();
|
$this->expectException();
|
||||||
|
|
Loading…
Add table
Reference in a new issue