code
stringlengths
31
1.39M
docstring
stringlengths
23
16.8k
func_name
stringlengths
1
126
language
stringclasses
1 value
repo
stringlengths
7
63
path
stringlengths
7
166
url
stringlengths
50
220
license
stringclasses
7 values
function testParseOptions($options, $safe = array()) { return $this->_parseOptions($options, $safe); }
test method for option parsing @return void
testParseOptions
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/js.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/js.test.php
MIT
function startTest() { $this->_asset = Configure::read('Asset.timestamp'); Configure::write('Asset.timestamp', false); $this->Js =& new JsHelper('JsBase'); $this->Js->Html =& new HtmlHelper(); $this->Js->Form =& new FormHelper(); $this->Js->Form->Html =& new HtmlHelper(); $this->Js->JsBaseEngine =& new JsBaseEngineHelper(); $view =& new JsHelperMockView(); ClassRegistry::addObject('view', $view); }
startTest method @access public @return void
startTest
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/js.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/js.test.php
MIT
function endTest() { Configure::write('Asset.timestamp', $this->_asset); ClassRegistry::removeObject('view'); unset($this->Js); }
endTest method @access public @return void
endTest
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/js.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/js.test.php
MIT
function _useMock() { $this->Js =& new JsHelper(array('TestJs')); $this->Js->TestJsEngine =& new TestJsEngineHelper($this); $this->Js->Html =& new HtmlHelper(); $this->Js->Form =& new FormHelper(); $this->Js->Form->Html =& new HtmlHelper(); }
Switches $this->Js to a mocked engine. @return void
_useMock
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/js.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/js.test.php
MIT
function testMethodDispatching() { $this->_useMock(); $this->Js->TestJsEngine->expectOnce('dispatchMethod', array(new PatternExpectation('/methodOne/i'), array())); $this->Js->methodOne(); $this->Js->TestEngine =& new StdClass(); $this->expectError(); $this->Js->someMethodThatSurelyDoesntExist(); }
test that methods dispatch internally and to the engine class @return void
testMethodDispatching
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/js.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/js.test.php
MIT
function testMethodDispatchWithBuffering() { $this->_useMock(); $this->Js->TestJsEngine->bufferedMethods = array('event', 'sortables'); $this->Js->TestJsEngine->setReturnValue('dispatchMethod', 'This is an event call', array('event', '*')); $this->Js->event('click', 'foo'); $result = $this->Js->getBuffer(); $this->assertEqual(count($result), 1); $this->assertEqual($result[0], 'This is an event call'); $result = $this->Js->event('click', 'foo', array('buffer' => false)); $buffer = $this->Js->getBuffer(); $this->assertTrue(empty($buffer)); $this->assertEqual($result, 'This is an event call'); $result = $this->Js->event('click', 'foo', false); $buffer = $this->Js->getBuffer(); $this->assertTrue(empty($buffer)); $this->assertEqual($result, 'This is an event call'); $this->Js->TestJsEngine->setReturnValue('dispatchMethod', 'I am not buffered.', array('effect', '*')); $result = $this->Js->effect('slideIn'); $buffer = $this->Js->getBuffer(); $this->assertTrue(empty($buffer)); $this->assertEqual($result, 'I am not buffered.'); $result = $this->Js->effect('slideIn', true); $buffer = $this->Js->getBuffer(); $this->assertNull($result); $this->assertEqual(count($buffer), 1); $this->assertEqual($buffer[0], 'I am not buffered.'); $result = $this->Js->effect('slideIn', array('speed' => 'slow'), true); $buffer = $this->Js->getBuffer(); $this->assertNull($result); $this->assertEqual(count($buffer), 1); $this->assertEqual($buffer[0], 'I am not buffered.'); $result = $this->Js->effect('slideIn', array('speed' => 'slow', 'buffer' => true)); $buffer = $this->Js->getBuffer(); $this->assertNull($result); $this->assertEqual(count($buffer), 1); $this->assertEqual($buffer[0], 'I am not buffered.'); }
Test that method dispatching respects buffer parameters and bufferedMethods Lists. @return void
testMethodDispatchWithBuffering
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/js.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/js.test.php
MIT
function testWriteScriptsNoFile() { $this->_useMock(); $this->Js->buffer('one = 1;'); $this->Js->buffer('two = 2;'); $result = $this->Js->writeBuffer(array('onDomReady' => false, 'cache' => false, 'clear' => false)); $expected = array( 'script' => array('type' => 'text/javascript'), $this->cDataStart, "one = 1;\ntwo = 2;", $this->cDataEnd, '/script', ); $this->assertTags($result, $expected, true); $this->Js->TestJsEngine->expectAtLeastOnce('domReady'); $result = $this->Js->writeBuffer(array('onDomReady' => true, 'cache' => false, 'clear' => false)); ClassRegistry::removeObject('view'); $view =& new JsHelperMockView(); ClassRegistry::addObject('view', $view); $view->expectCallCount('addScript', 1); $view->expectAt(0, 'addScript', array(new PatternExpectation('/one\s\=\s1;\ntwo\s\=\s2;/'))); $result = $this->Js->writeBuffer(array('onDomReady' => false, 'inline' => false, 'cache' => false)); }
test that writeScripts generates scripts inline. @return void
testWriteScriptsNoFile
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/js.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/js.test.php
MIT
function testWriteBufferNotInline() { $this->Js->set('foo', 1); $view =& new JsHelperMockView(); ClassRegistry::removeObject('view'); ClassRegistry::addObject('view', $view); $view->expectCallCount('addScript', 1); $pattern = new PatternExpectation('#<script type="text\/javascript">window.app \= \{"foo"\:1\}\;<\/script>#'); $view->expectAt(0, 'addScript', array($pattern)); $result = $this->Js->writeBuffer(array('onDomReady' => false, 'inline' => false, 'safe' => false)); }
test that writing the buffer with inline = false includes a script tag. @return void
testWriteBufferNotInline
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/js.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/js.test.php
MIT
function testWriteBufferAndXhr() { $this->_useMock(); $this->Js->params['isAjax'] = true; $this->Js->buffer('alert("test");'); $this->Js->TestJsEngine->expectCallCount('dispatchMethod', 0); $result = $this->Js->writeBuffer(); }
test that writeBuffer() sets domReady = false when the request is done by XHR. Including a domReady() when in XHR can cause issues as events aren't triggered by some libraries @return void
testWriteBufferAndXhr
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/js.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/js.test.php
MIT
function testWriteScriptsInFile() { if ($this->skipIf(!is_writable(JS), 'webroot/js is not Writable, script caching test has been skipped')) { return; } $this->Js->JsBaseEngine = new TestJsEngineHelper(); $this->Js->buffer('one = 1;'); $this->Js->buffer('two = 2;'); $result = $this->Js->writeBuffer(array('onDomReady' => false, 'cache' => true)); $expected = array( 'script' => array('type' => 'text/javascript', 'src' => 'preg:/(.)*\.js/'), ); $this->assertTags($result, $expected); preg_match('/src="(.*\.js)"/', $result, $filename); $this->assertTrue(file_exists(WWW_ROOT . $filename[1])); $contents = file_get_contents(WWW_ROOT . $filename[1]); $this->assertPattern('/one\s=\s1;\ntwo\s=\s2;/', $contents); @unlink(WWW_ROOT . $filename[1]); }
test that writeScripts makes files, and puts the events into them. @return void
testWriteScriptsInFile
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/js.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/js.test.php
MIT
function testLinkWithNoBuffering() { $this->_useMock(); $this->Js->TestJsEngine->setReturnValue('dispatchMethod', 'ajax code', array( 'request', array('/posts/view/1', array('update' => '#content')) )); $this->Js->TestJsEngine->setReturnValue('dispatchMethod', '-event handler-', array('event', '*')); $options = array('update' => '#content', 'buffer' => false); $result = $this->Js->link('test link', '/posts/view/1', $options); $expected = array( 'a' => array('id' => 'preg:/link-\d+/', 'href' => '/posts/view/1'), 'test link', '/a', 'script' => array('type' => 'text/javascript'), $this->cDataStart, '-event handler-', $this->cDataEnd, '/script' ); $this->assertTags($result, $expected); $options = array('update' => '#content', 'buffer' => false, 'safe' => false); $result = $this->Js->link('test link', '/posts/view/1', $options); $expected = array( 'a' => array('id' => 'preg:/link-\d+/', 'href' => '/posts/view/1'), 'test link', '/a', 'script' => array('type' => 'text/javascript'), '-event handler-', '/script' ); $this->assertTags($result, $expected); }
test that link() and no buffering returns an <a> and <script> tags. @return void
testLinkWithNoBuffering
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/js.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/js.test.php
MIT
function testObjectPassThrough() { $result = $this->Js->object(array('one' => 'first', 'two' => 'second')); $expected = '{"one":"first","two":"second"}'; $this->assertEqual($result, $expected); }
Test that Object::Object() is not breaking json output in JsHelper @return void
testObjectPassThrough
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/js.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/js.test.php
MIT
function testValuePassThrough() { $result = $this->Js->value('string "quote"', true); $expected = '"string \"quote\""'; $this->assertEqual($result, $expected); }
Test that inherited Helper::value() is overwritten in JsHelper::value() and calls JsBaseEngineHelper::value(). @return void
testValuePassThrough
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/js.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/js.test.php
MIT
function testSet() { $this->Js->set('loggedIn', true); $this->Js->set(array('height' => 'tall', 'color' => 'purple')); $result = $this->Js->getBuffer(); $expected = 'window.app = {"loggedIn":true,"height":"tall","color":"purple"};'; $this->assertEqual($result[0], $expected); $this->Js->set('loggedIn', true); $this->Js->set(array('height' => 'tall', 'color' => 'purple')); $this->Js->setVariable = 'WICKED'; $result = $this->Js->getBuffer(); $expected = 'window.WICKED = {"loggedIn":true,"height":"tall","color":"purple"};'; $this->assertEqual($result[0], $expected); $this->Js->set('loggedIn', true); $this->Js->set(array('height' => 'tall', 'color' => 'purple')); $this->Js->setVariable = 'Application.variables'; $result = $this->Js->getBuffer(); $expected = 'Application.variables = {"loggedIn":true,"height":"tall","color":"purple"};'; $this->assertEqual($result[0], $expected); }
test set()'ing variables to the Javascript buffer and controlling the output var name. @return void
testSet
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/js.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/js.test.php
MIT
function testSetVarsAtTopOfBufferedScripts() { $this->Js->set(array('height' => 'tall', 'color' => 'purple')); $this->Js->alert('hey you!', array('buffer' => true)); $this->Js->confirm('Are you sure?', array('buffer' => true)); $result = $this->Js->getBuffer(false); $expected = 'window.app = {"height":"tall","color":"purple"};'; $this->assertEqual($result[0], $expected); $this->assertEqual($result[1], 'alert("hey you!");'); $this->assertEqual($result[2], 'confirm("Are you sure?");'); }
test that vars set with Js->set() go to the top of the buffered scripts list. @return void
testSetVarsAtTopOfBufferedScripts
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/js.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/js.test.php
MIT
function startTest() { $this->JsEngine = new JsBaseEngineHelper(); }
startTest method @access public @return void
startTest
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/js.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/js.test.php
MIT
function endTest() { ClassRegistry::removeObject('view'); unset($this->JsEngine); }
endTest method @access public @return void
endTest
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/js.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/js.test.php
MIT
function testEscaping() { $result = $this->JsEngine->escape(''); $expected = ''; $this->assertEqual($result, $expected); $result = $this->JsEngine->escape('CakePHP' . "\n" . 'Rapid Development Framework'); $expected = 'CakePHP\\nRapid Development Framework'; $this->assertEqual($result, $expected); $result = $this->JsEngine->escape('CakePHP' . "\r\n" . 'Rapid Development Framework' . "\r" . 'For PHP'); $expected = 'CakePHP\\r\\nRapid Development Framework\\rFor PHP'; $this->assertEqual($result, $expected); $result = $this->JsEngine->escape('CakePHP: "Rapid Development Framework"'); $expected = 'CakePHP: \\"Rapid Development Framework\\"'; $this->assertEqual($result, $expected); $result = $this->JsEngine->escape("CakePHP: 'Rapid Development Framework'"); $expected = "CakePHP: 'Rapid Development Framework'"; $this->assertEqual($result, $expected); $result = $this->JsEngine->escape('my \\"string\\"'); $expected = 'my \\\\\\"string\\\\\\"'; $this->assertEqual($result, $expected); }
test escape string skills @return void
testEscaping
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/js.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/js.test.php
MIT
function testObject() { $this->JsEngine->useNative = false; $object = array('title' => 'New thing', 'indexes' => array(5, 6, 7, 8)); $result = $this->JsEngine->object($object); $expected = '{"title":"New thing","indexes":[5,6,7,8]}'; $this->assertEqual($result, $expected); $result = $this->JsEngine->object(array('default' => 0)); $expected = '{"default":0}'; $this->assertEqual($result, $expected); $result = $this->JsEngine->object(array( '2007' => array( 'Spring' => array( '1' => array('id' => 1, 'name' => 'Josh'), '2' => array('id' => 2, 'name' => 'Becky') ), 'Fall' => array( '1' => array('id' => 1, 'name' => 'Josh'), '2' => array('id' => 2, 'name' => 'Becky') ) ), '2006' => array( 'Spring' => array( '1' => array('id' => 1, 'name' => 'Josh'), '2' => array('id' => 2, 'name' => 'Becky') ), 'Fall' => array( '1' => array('id' => 1, 'name' => 'Josh'), '2' => array('id' => 2, 'name' => 'Becky') ) ) )); $expected = '{"2007":{"Spring":{"1":{"id":1,"name":"Josh"},"2":{"id":2,"name":"Becky"}},"Fall":{"1":{"id":1,"name":"Josh"},"2":{"id":2,"name":"Becky"}}},"2006":{"Spring":{"1":{"id":1,"name":"Josh"},"2":{"id":2,"name":"Becky"}},"Fall":{"1":{"id":1,"name":"Josh"},"2":{"id":2,"name":"Becky"}}}}'; $this->assertEqual($result, $expected); foreach (array('true' => true, 'false' => false, 'null' => null) as $expected => $data) { $result = $this->JsEngine->object($data); $this->assertEqual($result, $expected); } $object = array('title' => 'New thing', 'indexes' => array(5, 6, 7, 8), 'object' => array('inner' => array('value' => 1))); $result = $this->JsEngine->object($object, array('prefix' => 'PREFIX', 'postfix' => 'POSTFIX')); $this->assertPattern('/^PREFIX/', $result); $this->assertPattern('/POSTFIX$/', $result); $this->assertNoPattern('/.PREFIX./', $result); $this->assertNoPattern('/.POSTFIX./', $result); }
testObject encoding with non-native methods. @return void
testObject
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/js.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/js.test.php
MIT
function testObjectAgainstJsonDecode() { $skip = $this->skipIf(!function_exists('json_encode'), 'json_encode() not found, comparison tests skipped. %s'); if ($skip) { return; } $this->JsEngine->useNative = false; $data = array("simple string"); $result = $this->JsEngine->object($data); $this->assertEqual(json_decode($result), $data); $data = array('my "string"'); $result = $this->JsEngine->object($data); $this->assertEqual(json_decode($result), $data); $data = array('my \\"string\\"'); $result = $this->JsEngine->object($data); $this->assertEqual(json_decode($result), $data); }
test that JSON made with JsBaseEngineHelper::object() against json_decode() @return void
testObjectAgainstJsonDecode
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/js.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/js.test.php
MIT
function testOptionMapping() { $JsEngine = new OptionEngineHelper(); $result = $JsEngine->testMap(); $this->assertEqual($result, array()); $result = $JsEngine->testMap(array('foo' => 'bar', 'baz' => 'sho')); $this->assertEqual($result, array('foo' => 'bar', 'baz' => 'sho')); $result = $JsEngine->testMap(array('complete' => 'myFunc', 'type' => 'json', 'update' => '#element')); $this->assertEqual($result, array('success' => 'myFunc', 'dataType' => 'json', 'update' => '#element')); $result = $JsEngine->testMap(array('success' => 'myFunc', 'dataType' => 'json', 'update' => '#element')); $this->assertEqual($result, array('success' => 'myFunc', 'dataType' => 'json', 'update' => '#element')); }
test Mapping of options. @return void
testOptionMapping
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/js.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/js.test.php
MIT
function testOptionParsing() { $JsEngine = new OptionEngineHelper(); $result = $JsEngine->testParseOptions(array('url' => '/posts/view/1', 'key' => 1)); $expected = 'key:1, url:"\\/posts\\/view\\/1"'; $this->assertEqual($result, $expected); $result = $JsEngine->testParseOptions(array('url' => '/posts/view/1', 'success' => 'doSuccess'), array('success')); $expected = 'success:doSuccess, url:"\\/posts\\/view\\/1"'; $this->assertEqual($result, $expected); }
test that option parsing escapes strings and saves what is supposed to be saved. @return void
testOptionParsing
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/js.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/js.test.php
MIT
function testDomReady() { $result = $this->Moo->domReady('foo.name = "bar";'); $expected = 'window.addEvent("domready", function (event) {foo.name = "bar";});'; $this->assertEqual($result, $expected); }
test dom ready event creation @return void
testDomReady
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/mootools_engine.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/mootools_engine.test.php
MIT
function testSortable() { $this->Moo->get('#myList'); $result = $this->Moo->sortable(array( 'distance' => 5, 'containment' => 'parent', 'start' => 'onStart', 'complete' => 'onStop', 'sort' => 'onSort', 'wrapCallbacks' => false )); $expected = 'var jsSortable = new Sortables($("myList"), {constrain:"parent", onComplete:onStop, onSort:onSort, onStart:onStart, snap:5});'; $this->assertEqual($result, $expected); }
test sortable list generation @return void
testSortable
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/mootools_engine.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/mootools_engine.test.php
MIT
function testSerializeForm() { $this->Moo->get('#element'); $result = $this->Moo->serializeForm(array('isForm' => true)); $expected = '$("element").toQueryString();'; $this->assertEqual($result, $expected); $result = $this->Moo->serializeForm(array('isForm' => true, 'inline' => true)); $expected = '$("element").toQueryString()'; $this->assertEqual($result, $expected); $result = $this->Moo->serializeForm(array('isForm' => false)); $expected = '$($("element").form).toQueryString();'; $this->assertEqual($result, $expected); $result = $this->Moo->serializeForm(array('isForm' => false, 'inline' => true)); $expected = '$($("element").form).toQueryString()'; $this->assertEqual($result, $expected); }
test the serializeForm implementation. @return void
testSerializeForm
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/mootools_engine.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/mootools_engine.test.php
MIT
function startTest() { $this->Number =& new NumberHelper(); }
setUp method @access public @return void
startTest
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/number.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/number.test.php
MIT
function testFormat() { $value = '100100100'; $result = $this->Number->format($value, '#'); $expected = '#100,100,100'; $this->assertEqual($expected, $result); $result = $this->Number->format($value, 3); $expected = '100,100,100.000'; $this->assertEqual($expected, $result); $result = $this->Number->format($value); $expected = '100,100,100'; $this->assertEqual($expected, $result); $result = $this->Number->format($value, '-'); $expected = '100-100-100'; $this->assertEqual($expected, $result); }
testFormatAndCurrency method @access public @return void
testFormat
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/number.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/number.test.php
MIT
function testCurrencyAddFormat() { $this->Number->addFormat('NOK', array('before' => 'Kr. ')); $result = $this->Number->currency(1000, 'NOK'); $expected = 'Kr. 1,000.00'; $this->assertEqual($expected,$result); $this->Number->addFormat('Other', array('before' => '$$ ', 'after' => 'c!')); $result = $this->Number->currency(0.22, 'Other'); $expected = '22c!'; $this->assertEqual($expected,$result); $result = $this->Number->currency(-10, 'Other'); $expected = '($$ 10.00)'; $this->assertEqual($expected,$result); $this->Number->addFormat('Other2', array('before' => '$ ')); $result = $this->Number->currency(0.22, 'Other2'); $expected = '$ 0.22'; $this->assertEqual($expected,$result); }
Test adding currency format options to the number helper @access public @return void
testCurrencyAddFormat
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/number.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/number.test.php
MIT
function testCurrencyPositive() { $value = '100100100'; $result = $this->Number->currency($value); $expected = '$100,100,100.00'; $this->assertEqual($expected, $result); $result = $this->Number->currency($value, 'USD', array('before'=> '#')); $expected = '#100,100,100.00'; $this->assertEqual($expected, $result); $result = $this->Number->currency($value, false); $expected = '100,100,100.00'; $this->assertEqual($expected, $result); $result = $this->Number->currency($value, 'USD'); $expected = '$100,100,100.00'; $this->assertEqual($expected, $result); $result = $this->Number->currency($value, 'EUR'); $expected = '&#8364;100.100.100,00'; $this->assertEqual($expected, $result); $result = $this->Number->currency($value, 'GBP'); $expected = '&#163;100,100,100.00'; $this->assertEqual($expected, $result); }
testCurrencyPositive method @access public @return void
testCurrencyPositive
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/number.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/number.test.php
MIT
function testCurrencyNegative() { $value = '-100100100'; $result = $this->Number->currency($value); $expected = '($100,100,100.00)'; $this->assertEqual($expected, $result); $result = $this->Number->currency($value, 'EUR'); $expected = '(&#8364;100.100.100,00)'; $this->assertEqual($expected, $result); $result = $this->Number->currency($value, 'GBP'); $expected = '(&#163;100,100,100.00)'; $this->assertEqual($expected, $result); $result = $this->Number->currency($value, 'USD', array('negative'=>'-')); $expected = '-$100,100,100.00'; $this->assertEqual($expected, $result); $result = $this->Number->currency($value, 'EUR', array('negative'=>'-')); $expected = '-&#8364;100.100.100,00'; $this->assertEqual($expected, $result); $result = $this->Number->currency($value, 'GBP', array('negative'=>'-')); $expected = '-&#163;100,100,100.00'; $this->assertEqual($expected, $result); }
testCurrencyNegative method @access public @return void
testCurrencyNegative
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/number.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/number.test.php
MIT
function testCurrencyCentsPositive() { $value = '0.99'; $result = $this->Number->currency($value, 'USD'); $expected = '99c'; $this->assertEqual($expected, $result); $result = $this->Number->currency($value, 'EUR'); $expected = '&#8364;0,99'; $this->assertEqual($expected, $result); $result = $this->Number->currency($value, 'GBP'); $expected = '99p'; $this->assertEqual($expected, $result); }
testCurrencyCentsPositive method @access public @return void
testCurrencyCentsPositive
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/number.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/number.test.php
MIT
function testCurrencyCentsNegative() { $value = '-0.99'; $result = $this->Number->currency($value, 'USD'); $expected = '(99c)'; $this->assertEqual($expected, $result); $result = $this->Number->currency($value, 'EUR'); $expected = '(&#8364;0,99)'; $this->assertEqual($expected, $result); $result = $this->Number->currency($value, 'GBP'); $expected = '(99p)'; $this->assertEqual($expected, $result); $result = $this->Number->currency($value, 'USD', array('negative'=>'-')); $expected = '-99c'; $this->assertEqual($expected, $result); $result = $this->Number->currency($value, 'EUR', array('negative'=>'-')); $expected = '-&#8364;0,99'; $this->assertEqual($expected, $result); $result = $this->Number->currency($value, 'GBP', array('negative'=>'-')); $expected = '-99p'; $this->assertEqual($expected, $result); }
testCurrencyCentsNegative method @access public @return void
testCurrencyCentsNegative
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/number.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/number.test.php
MIT
function testCurrencyZero() { $value = '0'; $result = $this->Number->currency($value, 'USD'); $expected = '$0.00'; $this->assertEqual($expected, $result); $result = $this->Number->currency($value, 'EUR'); $expected = '&#8364;0,00'; $this->assertEqual($expected, $result); $result = $this->Number->currency($value, 'GBP'); $expected = '&#163;0.00'; $this->assertEqual($expected, $result); $result = $this->Number->currency($value, 'GBP', array('zero' => 'FREE!')); $expected = 'FREE!'; $this->assertEqual($expected, $result); }
testCurrencyZero method @access public @return void
testCurrencyZero
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/number.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/number.test.php
MIT
function testCurrencyOptions() { $value = '1234567.89'; $result = $this->Number->currency($value, null, array('before' => 'GBP')); $expected = 'GBP1,234,567.89'; $this->assertEqual($expected, $result); $result = $this->Number->currency($value, 'GBP', array('places' => 0)); $expected = '&#163;1,234,568'; $this->assertEqual($expected, $result); $result = $this->Number->currency('1234567.8912345', null, array('before' => 'GBP', 'places' => 3)); $expected = 'GBP1,234,567.891'; $this->assertEqual($expected, $result); $result = $this->Number->currency('650.120001', null, array('before' => 'GBP', 'places' => 4)); $expected = 'GBP650.1200'; $this->assertEqual($expected, $result); $result = $this->Number->currency($value, 'GBP', array('escape' => true)); $expected = '&amp;#163;1,234,567.89'; $this->assertEqual($expected, $result); $result = $this->Number->currency('0.35', 'USD', array('after' => false)); $expected = '$0.35'; $this->assertEqual($expected, $result); $result = $this->Number->currency('0.35', 'GBP', array('after' => false)); $expected = '&#163;0.35'; $this->assertEqual($expected, $result); $result = $this->Number->currency('0.35', 'GBP'); $expected = '35p'; $this->assertEqual($expected, $result); $result = $this->Number->currency('0.35', 'EUR'); $expected = '&#8364;0,35'; $this->assertEqual($expected, $result); }
testCurrencyOptions method @access public @return void
testCurrencyOptions
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/number.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/number.test.php
MIT
function testToReadableSize() { $result = $this->Number->toReadableSize(0); $expected = '0 Bytes'; $this->assertEqual($expected, $result); $result = $this->Number->toReadableSize(1); $expected = '1 Byte'; $this->assertEqual($expected, $result); $result = $this->Number->toReadableSize(45); $expected = '45 Bytes'; $this->assertEqual($expected, $result); $result = $this->Number->toReadableSize(1023); $expected = '1023 Bytes'; $this->assertEqual($expected, $result); $result = $this->Number->toReadableSize(1024); $expected = '1 KB'; $this->assertEqual($expected, $result); $result = $this->Number->toReadableSize(1024*512); $expected = '512 KB'; $this->assertEqual($expected, $result); $result = $this->Number->toReadableSize(1024*1024-1); $expected = '1.00 MB'; $this->assertEqual($expected, $result); $result = $this->Number->toReadableSize(1024*1024*512); $expected = '512.00 MB'; $this->assertEqual($expected, $result); $result = $this->Number->toReadableSize(1024*1024*1024-1); $expected = '1.00 GB'; $this->assertEqual($expected, $result); $result = $this->Number->toReadableSize(1024*1024*1024*512); $expected = '512.00 GB'; $this->assertEqual($expected, $result); $result = $this->Number->toReadableSize(1024*1024*1024*1024-1); $expected = '1.00 TB'; $this->assertEqual($expected, $result); $result = $this->Number->toReadableSize(1024*1024*1024*1024*512); $expected = '512.00 TB'; $this->assertEqual($expected, $result); $result = $this->Number->toReadableSize(1024*1024*1024*1024*1024-1); $expected = '1024.00 TB'; $this->assertEqual($expected, $result); $result = $this->Number->toReadableSize(1024*1024*1024*1024*1024*1024); $expected = (1024 * 1024) . '.00 TB'; $this->assertEqual($expected, $result); }
testToReadableSize method @access public @return void
testToReadableSize
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/number.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/number.test.php
MIT
function testToPercentage() { $result = $this->Number->toPercentage(45, 0); $expected = '45%'; $this->assertEqual($result, $expected); $result = $this->Number->toPercentage(45, 2); $expected = '45.00%'; $this->assertEqual($result, $expected); $result = $this->Number->toPercentage(0, 0); $expected = '0%'; $this->assertEqual($result, $expected); $result = $this->Number->toPercentage(0, 4); $expected = '0.0000%'; $this->assertEqual($result, $expected); }
testToPercentage method @access public @return void
testToPercentage
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/number.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/number.test.php
MIT
function setUp() { $this->Paginator = new PaginatorHelper(array('ajax' => 'Ajax')); $this->Paginator->params['paging'] = array( 'Article' => array( 'current' => 9, 'count' => 62, 'prevPage' => false, 'nextPage' => true, 'pageCount' => 7, 'defaults' => array( 'order' => array('Article.date' => 'asc'), 'limit' => 9, 'conditions' => array() ), 'options' => array( 'order' => array('Article.date' => 'asc'), 'limit' => 9, 'page' => 1, 'conditions' => array() ) ) ); $this->Paginator->Html =& new HtmlHelper(); $this->Paginator->Ajax =& new AjaxHelper(); $this->Paginator->Ajax->Html =& new HtmlHelper(); $this->Paginator->Ajax->Javascript =& new JavascriptHelper(); $this->Paginator->Ajax->Form =& new FormHelper(); Configure::write('Routing.prefixes', array()); Router::reload(); }
setUp method @access public @return void
setUp
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/paginator.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/paginator.test.php
MIT
function testHasPrevious() { $this->assertIdentical($this->Paginator->hasPrev(), false); $this->Paginator->params['paging']['Article']['prevPage'] = true; $this->assertIdentical($this->Paginator->hasPrev(), true); $this->Paginator->params['paging']['Article']['prevPage'] = false; }
testHasPrevious method @access public @return void
testHasPrevious
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/paginator.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/paginator.test.php
MIT
function testHasNext() { $this->assertIdentical($this->Paginator->hasNext(), true); $this->Paginator->params['paging']['Article']['nextPage'] = false; $this->assertIdentical($this->Paginator->hasNext(), false); $this->Paginator->params['paging']['Article']['nextPage'] = true; }
testHasNext method @access public @return void
testHasNext
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/paginator.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/paginator.test.php
MIT
function testDisabledLink() { $this->Paginator->params['paging']['Article']['nextPage'] = false; $this->Paginator->params['paging']['Article']['page'] = 1; $result = $this->Paginator->next('Next', array(), true); $expected = '<span class="next">Next</span>'; $this->assertEqual($result, $expected); $this->Paginator->params['paging']['Article']['prevPage'] = false; $result = $this->Paginator->prev('prev', array('update' => 'theList', 'indicator' => 'loading', 'url' => array('controller' => 'posts')), null, array('class' => 'disabled', 'tag' => 'span')); $expected = array( 'span' => array('class' => 'disabled'), 'prev', '/span' ); $this->assertTags($result, $expected); }
testDisabledLink method @access public @return void
testDisabledLink
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/paginator.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/paginator.test.php
MIT
function testSortLinks() { Router::reload(); Router::parse('/'); Router::setRequestInfo(array( array('plugin' => null, 'controller' => 'accounts', 'action' => 'index', 'pass' => array(), 'form' => array(), 'url' => array('url' => 'accounts/'), 'bare' => 0), array('plugin' => null, 'controller' => null, 'action' => null, 'base' => '/officespace', 'here' => '/officespace/accounts/', 'webroot' => '/officespace/', 'passedArgs' => array()) )); $this->Paginator->options(array('url' => array('param'))); $result = $this->Paginator->sort('title'); $expected = array( 'a' => array('href' => '/officespace/accounts/index/param/page:1/sort:title/direction:asc'), 'Title', '/a' ); $this->assertTags($result, $expected); $result = $this->Paginator->sort('date'); $expected = array( 'a' => array('href' => '/officespace/accounts/index/param/page:1/sort:date/direction:desc', 'class' => 'asc'), 'Date', '/a' ); $this->assertTags($result, $expected); $result = $this->Paginator->numbers(array('modulus'=> '2', 'url'=> array('controller'=>'projects', 'action'=>'sort'),'update'=>'list')); $this->assertPattern('/\/projects\/sort\/page:2/', $result); $this->assertPattern('/<script type="text\/javascript">\s*' . str_replace('/', '\\/', preg_quote('//<![CDATA[')) . '\s*Event.observe/', $result); $result = $this->Paginator->sort('TestTitle', 'title'); $expected = array( 'a' => array('href' => '/officespace/accounts/index/param/page:1/sort:title/direction:asc'), 'TestTitle', '/a' ); $this->assertTags($result, $expected); $result = $this->Paginator->sort(array('asc' => 'ascending', 'desc' => 'descending'), 'title'); $expected = array( 'a' => array('href' => '/officespace/accounts/index/param/page:1/sort:title/direction:asc'), 'ascending', '/a' ); $this->assertTags($result, $expected); $this->Paginator->params['paging']['Article']['options']['sort'] = 'title'; $result = $this->Paginator->sort(array('asc' => 'ascending', 'desc' => 'descending'), 'title'); $expected = array( 'a' => array('href' => '/officespace/accounts/index/param/page:1/sort:title/direction:desc', 'class' => 'asc'), 'descending', '/a' ); $this->assertTags($result, $expected); $this->Paginator->params['paging']['Article']['options']['order'] = array('Article.title' => 'desc'); $this->Paginator->params['paging']['Article']['options']['sort'] = null; $result = $this->Paginator->sort('title'); $this->assertPattern('/\/accounts\/index\/param\/page:1\/sort:title\/direction:asc" class="desc">Title<\/a>$/', $result); $this->Paginator->params['paging']['Article']['options']['order'] = array('Article.title' => 'asc'); $this->Paginator->params['paging']['Article']['options']['sort'] = null; $result = $this->Paginator->sort('title'); $this->assertPattern('/\/accounts\/index\/param\/page:1\/sort:title\/direction:desc" class="asc">Title<\/a>$/', $result); $this->Paginator->params['paging']['Article']['options']['order'] = array('Article.title' => 'desc'); $this->Paginator->params['paging']['Article']['options']['sort'] = null; $result = $this->Paginator->sort('Title', 'title', array('direction' => 'desc')); $this->assertPattern('/\/accounts\/index\/param\/page:1\/sort:title\/direction:asc" class="desc">Title<\/a>$/', $result); $this->Paginator->params['paging']['Article']['options']['order'] = array('Article.title' => 'desc'); $this->Paginator->params['paging']['Article']['options']['sort'] = null; $result = $this->Paginator->sort('Title', 'title', array('direction' => 'asc')); $this->assertPattern('/\/accounts\/index\/param\/page:1\/sort:title\/direction:asc" class="desc">Title<\/a>$/', $result); $this->Paginator->params['paging']['Article']['options']['order'] = array('Article.title' => 'asc'); $this->Paginator->params['paging']['Article']['options']['sort'] = null; $result = $this->Paginator->sort('Title', 'title', array('direction' => 'asc')); $this->assertPattern('/\/accounts\/index\/param\/page:1\/sort:title\/direction:desc" class="asc">Title<\/a>$/', $result); $this->Paginator->params['paging']['Article']['options']['order'] = array('Article.title' => 'asc'); $this->Paginator->params['paging']['Article']['options']['sort'] = null; $result = $this->Paginator->sort('Title', 'title', array('direction' => 'desc')); $this->assertPattern('/\/accounts\/index\/param\/page:1\/sort:title\/direction:desc" class="asc">Title<\/a>$/', $result); $this->Paginator->params['paging']['Article']['options']['order'] = array('Article.title' => 'asc'); $this->Paginator->params['paging']['Article']['options']['sort'] = null; $result = $this->Paginator->sort('Title', 'title', array('direction' => 'desc', 'class' => 'foo')); $this->assertPattern('/\/accounts\/index\/param\/page:1\/sort:title\/direction:desc" class="foo asc">Title<\/a>$/', $result); }
testSortLinks method @access public @return void
testSortLinks
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/paginator.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/paginator.test.php
MIT
function testSortLinkWithVirtualField() { Router::setRequestInfo(array( array('plugin' => null, 'controller' => 'accounts', 'action' => 'index', 'pass' => array(), 'form' => array(), 'url' => array('url' => 'accounts/')), array('base' => '', 'here' => '/accounts/', 'webroot' => '/') )); $this->Paginator->params['paging']['Article']['options']['order'] = array('full_name' => 'asc'); $result = $this->Paginator->sort('Article.full_name'); $expected = array( 'a' => array('href' => '/accounts/index/page:1/sort:Article.full_name/direction:desc', 'class' => 'asc'), 'Article.full Name', '/a' ); $this->assertTags($result, $expected); $result = $this->Paginator->sort('full_name'); $expected = array( 'a' => array('href' => '/accounts/index/page:1/sort:full_name/direction:desc', 'class' => 'asc'), 'Full Name', '/a' ); $this->assertTags($result, $expected); $this->Paginator->params['paging']['Article']['options']['order'] = array('full_name' => 'desc'); $result = $this->Paginator->sort('Article.full_name'); $expected = array( 'a' => array('href' => '/accounts/index/page:1/sort:Article.full_name/direction:asc', 'class' => 'desc'), 'Article.full Name', '/a' ); $this->assertTags($result, $expected); $result = $this->Paginator->sort('full_name'); $expected = array( 'a' => array('href' => '/accounts/index/page:1/sort:full_name/direction:asc', 'class' => 'desc'), 'Full Name', '/a' ); $this->assertTags($result, $expected); }
test that sort() works with virtual field order options. @return void
testSortLinkWithVirtualField
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/paginator.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/paginator.test.php
MIT
function testSortLinksUsingDirectionOption(){ Router::reload(); Router::parse('/'); Router::setRequestInfo(array( array('plugin' => null, 'controller' => 'accounts', 'action' => 'index', 'pass' => array(), 'form' => array(), 'url' => array('url' => 'accounts/', 'mod_rewrite' => 'true'), 'bare' => 0), array('plugin' => null, 'controller' => null, 'action' => null, 'base' => '/', 'here' => '/accounts/', 'webroot' => '/', 'passedArgs' => array()) )); $this->Paginator->options(array('url' => array('param'))); $result = $this->Paginator->sort('TestTitle', 'title', array('direction' => 'desc')); $expected = array( 'a' => array('href' => '/accounts/index/param/page:1/sort:title/direction:desc'), 'TestTitle', '/a' ); $this->assertTags($result, $expected); $result = $this->Paginator->sort(array('asc' => 'ascending', 'desc' => 'descending'), 'title', array('direction' => 'desc')); $expected = array( 'a' => array('href' => '/accounts/index/param/page:1/sort:title/direction:desc'), 'descending', '/a' ); $this->assertTags($result, $expected); }
testSortLinksUsingDirectionOption method @access public @return void
testSortLinksUsingDirectionOption
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/paginator.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/paginator.test.php
MIT
function testSortLinksUsingDotNotation() { Router::reload(); Router::parse('/'); Router::setRequestInfo(array( array('plugin' => null, 'controller' => 'accounts', 'action' => 'index', 'pass' => array(), 'form' => array(), 'url' => array('url' => 'accounts/', 'mod_rewrite' => 'true'), 'bare' => 0), array('plugin' => null, 'controller' => null, 'action' => null, 'base' => '/officespace', 'here' => '/officespace/accounts/', 'webroot' => '/officespace/', 'passedArgs' => array()) )); $this->Paginator->params['paging']['Article']['options']['order'] = array('Article.title' => 'desc'); $result = $this->Paginator->sort('Title','Article.title'); $expected = array( 'a' => array('href' => '/officespace/accounts/index/page:1/sort:Article.title/direction:asc', 'class' => 'desc'), 'Title', '/a' ); $this->assertTags($result, $expected); $this->Paginator->params['paging']['Article']['options']['order'] = array('Article.title' => 'asc'); $result = $this->Paginator->sort('Title','Article.title'); $expected = array( 'a' => array('href' => '/officespace/accounts/index/page:1/sort:Article.title/direction:desc', 'class' => 'asc'), 'Title', '/a' ); $this->assertTags($result, $expected); $this->Paginator->params['paging']['Article']['options']['order'] = array('Account.title' => 'asc'); $result = $this->Paginator->sort('title'); $expected = array( 'a' => array('href' => '/officespace/accounts/index/page:1/sort:title/direction:asc'), 'Title', '/a' ); $this->assertTags($result, $expected); }
testSortLinksUsingDotNotation method @access public @return void
testSortLinksUsingDotNotation
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/paginator.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/paginator.test.php
MIT
function testSortKey() { $result = $this->Paginator->sortKey(null, array( 'order' => array('Article.title' => 'desc' ))); $this->assertEqual('Article.title', $result); $result = $this->Paginator->sortKey('Article', array('sort' => 'Article.title')); $this->assertEqual($result, 'Article.title'); $result = $this->Paginator->sortKey('Article', array('sort' => 'Article')); $this->assertEqual($result, 'Article'); }
testSortKey method @access public @return void
testSortKey
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/paginator.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/paginator.test.php
MIT
function testSortDir() { $result = $this->Paginator->sortDir(); $expected = 'asc'; $this->assertEqual($result, $expected); $this->Paginator->params['paging']['Article']['options']['order'] = array('Article.title' => 'desc'); $result = $this->Paginator->sortDir(); $expected = 'desc'; $this->assertEqual($result, $expected); unset($this->Paginator->params['paging']['Article']['options']); $this->Paginator->params['paging']['Article']['options']['order'] = array('Article.title' => 'asc'); $result = $this->Paginator->sortDir(); $expected = 'asc'; $this->assertEqual($result, $expected); unset($this->Paginator->params['paging']['Article']['options']); $this->Paginator->params['paging']['Article']['options']['order'] = array('title' => 'desc'); $result = $this->Paginator->sortDir(); $expected = 'desc'; $this->assertEqual($result, $expected); unset($this->Paginator->params['paging']['Article']['options']); $this->Paginator->params['paging']['Article']['options']['order'] = array('title' => 'asc'); $result = $this->Paginator->sortDir(); $expected = 'asc'; $this->assertEqual($result, $expected); unset($this->Paginator->params['paging']['Article']['options']); $this->Paginator->params['paging']['Article']['options']['direction'] = 'asc'; $result = $this->Paginator->sortDir(); $expected = 'asc'; $this->assertEqual($result, $expected); unset($this->Paginator->params['paging']['Article']['options']); $this->Paginator->params['paging']['Article']['options']['direction'] = 'desc'; $result = $this->Paginator->sortDir(); $expected = 'desc'; $this->assertEqual($result, $expected); unset($this->Paginator->params['paging']['Article']['options']); $result = $this->Paginator->sortDir('Article', array('direction' => 'asc')); $expected = 'asc'; $this->assertEqual($result, $expected); $result = $this->Paginator->sortDir('Article', array('direction' => 'desc')); $expected = 'desc'; $this->assertEqual($result, $expected); $result = $this->Paginator->sortDir('Article', array('direction' => 'asc')); $expected = 'asc'; $this->assertEqual($result, $expected); }
testSortDir method @access public @return void
testSortDir
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/paginator.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/paginator.test.php
MIT
function testSortAdminLinks() { Configure::write('Routing.prefixes', array('admin')); Router::reload(); Router::setRequestInfo(array( array('pass' => array(), 'named' => array(), 'controller' => 'users', 'plugin' => null, 'action' => 'admin_index', 'prefix' => 'admin', 'admin' => true, 'url' => array('ext' => 'html', 'url' => 'admin/users'), 'form' => array()), array('base' => '', 'here' => '/admin/users', 'webroot' => '/') )); Router::parse('/admin/users'); $this->Paginator->params['paging']['Article']['page'] = 1; $result = $this->Paginator->next('Next'); $expected = array( '<span', 'a' => array('href' => '/admin/users/index/page:2', 'class' => 'next'), 'Next', '/a', '/span' ); $this->assertTags($result, $expected); Router::reload(); Router::setRequestInfo(array( array('plugin' => null, 'controller' => 'test', 'action' => 'admin_index', 'pass' => array(), 'prefix' => 'admin', 'admin' => true, 'form' => array(), 'url' => array('url' => 'admin/test')), array('plugin' => null, 'controller' => null, 'action' => null, 'base' => '', 'here' => '/admin/test', 'webroot' => '/') )); Router::parse('/'); $this->Paginator->options(array('url' => array('param'))); $result = $this->Paginator->sort('title'); $expected = array( 'a' => array('href' => '/admin/test/index/param/page:1/sort:title/direction:asc'), 'Title', '/a' ); $this->assertTags($result, $expected); $this->Paginator->options(array('url' => array('param'))); $result = $this->Paginator->sort('Title', 'Article.title'); $expected = array( 'a' => array('href' => '/admin/test/index/param/page:1/sort:Article.title/direction:asc'), 'Title', '/a' ); $this->assertTags($result, $expected); }
testSortAdminLinks method @access public @return void
testSortAdminLinks
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/paginator.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/paginator.test.php
MIT
function testUrlGeneration() { $result = $this->Paginator->sort('controller'); $expected = array( 'a' => array('href' => '/index/page:1/sort:controller/direction:asc'), 'Controller', '/a' ); $this->assertTags($result, $expected); $result = $this->Paginator->url(); $this->assertEqual($result, '/index/page:1'); $this->Paginator->params['paging']['Article']['options']['page'] = 2; $result = $this->Paginator->url(); $this->assertEqual($result, '/index/page:2'); $options = array('order' => array('Article' => 'desc')); $result = $this->Paginator->url($options); $this->assertEqual($result, '/index/page:2/sort:Article/direction:desc'); $this->Paginator->params['paging']['Article']['options']['page'] = 3; $options = array('order' => array('Article.name' => 'desc')); $result = $this->Paginator->url($options); $this->assertEqual($result, '/index/page:3/sort:Article.name/direction:desc'); }
testUrlGeneration method @access public @return void
testUrlGeneration
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/paginator.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/paginator.test.php
MIT
function testUrlGenerationWithPrefixes() { $_back = Configure::read('Routing'); Configure::write('Routing.prefixes', array('members')); Router::reload(); Router::parse('/'); Router::setRequestInfo( array( array('controller' => 'posts', 'action' => 'index', 'form' => array(), 'url' => array(), 'plugin' => null), array('plugin' => null, 'controller' => null, 'action' => null, 'base' => '', 'here' => 'posts/index', 'webroot' => '/') )); $this->Paginator->params['paging']['Article']['options']['page'] = 2; $this->Paginator->params['paging']['Article']['page'] = 2; $this->Paginator->params['paging']['Article']['prevPage'] = true; $options = array('members' => true); $result = $this->Paginator->url($options); $expected = '/members/posts/index/page:2'; $this->assertEqual($result, $expected); $result = $this->Paginator->sort('name', null, array('url' => $options)); $expected = array( 'a' => array('href' => '/members/posts/index/page:2/sort:name/direction:asc'), 'Name', '/a' ); $this->assertTags($result, $expected, true); $result = $this->Paginator->next('next', array('url' => $options)); $expected = array( '<span', 'a' => array('href' => '/members/posts/index/page:3', 'class' => 'next'), 'next', '/a', '/span' ); $this->assertTags($result, $expected); $result = $this->Paginator->prev('prev', array('url' => $options)); $expected = array( '<span', 'a' => array('href' => '/members/posts/index/page:1', 'class' => 'prev'), 'prev', '/a', '/span' ); $this->assertTags($result, $expected); $options = array('members' => true, 'controller' => 'posts', 'order' => array('name' => 'desc')); $result = $this->Paginator->url($options); $expected = '/members/posts/index/page:2/sort:name/direction:desc'; $this->assertEqual($result, $expected); $options = array('controller' => 'posts', 'order' => array('Article.name' => 'desc')); $result = $this->Paginator->url($options); $expected = '/posts/index/page:2/sort:Article.name/direction:desc'; $this->assertEqual($result, $expected); Configure::write('Routing', $_back); }
test URL generation with prefix routes @access public @return void
testUrlGenerationWithPrefixes
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/paginator.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/paginator.test.php
MIT
function testOptions() { $this->Paginator->options('myDiv'); $this->assertEqual('myDiv', $this->Paginator->options['update']); $this->Paginator->options = array(); $this->Paginator->params = array(); $options = array('paging' => array('Article' => array( 'order' => 'desc', 'sort' => 'title' ))); $this->Paginator->options($options); $expected = array('Article' => array( 'order' => 'desc', 'sort' => 'title' )); $this->assertEqual($expected, $this->Paginator->params['paging']); $this->Paginator->options = array(); $this->Paginator->params = array(); $options = array('Article' => array( 'order' => 'desc', 'sort' => 'title' )); $this->Paginator->options($options); $this->assertEqual($expected, $this->Paginator->params['paging']); $options = array('paging' => array('Article' => array( 'order' => 'desc', 'sort' => 'Article.title' ))); $this->Paginator->options($options); $expected = array('Article' => array( 'order' => 'desc', 'sort' => 'Article.title' )); $this->assertEqual($expected, $this->Paginator->params['paging']); }
testOptions method @access public @return void
testOptions
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/paginator.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/paginator.test.php
MIT
function testPassedArgsMergingWithUrlOptions() { Router::reload(); Router::parse('/'); Router::setRequestInfo(array( array('plugin' => null, 'controller' => 'articles', 'action' => 'index', 'pass' => array('2'), 'named' => array('foo' => 'bar'), 'form' => array(), 'url' => array('url' => 'articles/index/2/foo:bar'), 'bare' => 0), array('plugin' => null, 'controller' => null, 'action' => null, 'base' => '/', 'here' => '/articles/', 'webroot' => '/', 'passedArgs' => array(0 => '2', 'foo' => 'bar')) )); $this->Paginator->params['paging'] = array( 'Article' => array( 'page' => 1, 'current' => 3, 'count' => 13, 'prevPage' => false, 'nextPage' => true, 'pageCount' => 8, 'defaults' => array( 'limit' => 3, 'step' => 1, 'order' => array(), 'conditions' => array() ), 'options' => array( 'page' => 1, 'limit' => 3, 'order' => array(), 'conditions' => array() ) ) ); $this->Paginator->params['pass'] = array(2); $this->Paginator->params['named'] = array('foo' => 'bar'); $this->Paginator->beforeRender(); $result = $this->Paginator->sort('title'); $expected = array( 'a' => array('href' => '/articles/index/2/page:1/foo:bar/sort:title/direction:asc'), 'Title', '/a' ); $this->assertTags($result, $expected); $result = $this->Paginator->numbers(); $expected = array( array('span' => array('class' => 'current')), '1', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/articles/index/2/page:2/foo:bar')), '2', '/a', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/articles/index/2/page:3/foo:bar')), '3', '/a', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/articles/index/2/page:4/foo:bar')), '4', '/a', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/articles/index/2/page:5/foo:bar')), '5', '/a', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/articles/index/2/page:6/foo:bar')), '6', '/a', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/articles/index/2/page:7/foo:bar')), '7', '/a', '/span', ); $this->assertTags($result, $expected); $result = $this->Paginator->next('Next'); $expected = array( '<span', 'a' => array('href' => '/articles/index/2/page:2/foo:bar', 'class' => 'next'), 'Next', '/a', '/span' ); $this->assertTags($result, $expected); }
testPassedArgsMergingWithUrlOptions method @access public @return void
testPassedArgsMergingWithUrlOptions
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/paginator.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/paginator.test.php
MIT
function testPagingLinks() { $this->Paginator->params['paging'] = array('Client' => array( 'page' => 1, 'current' => 3, 'count' => 13, 'prevPage' => false, 'nextPage' => true, 'pageCount' => 5, 'defaults' => array('limit' => 3, 'step' => 1, 'order' => array('Client.name' => 'DESC'), 'conditions' => array()), 'options' => array('page' => 1, 'limit' => 3, 'order' => array('Client.name' => 'DESC'), 'conditions' => array())) ); $result = $this->Paginator->prev('<< Previous', null, null, array('class' => 'disabled')); $expected = array( 'span' => array('class' => 'disabled'), '&lt;&lt; Previous', '/span' ); $this->assertTags($result, $expected); $result = $this->Paginator->prev('<< Previous', null, null, array('class' => 'disabled', 'tag' => 'div')); $expected = array( 'div' => array('class' => 'disabled'), '&lt;&lt; Previous', '/div' ); $this->assertTags($result, $expected); $this->Paginator->params['paging']['Client']['page'] = 2; $this->Paginator->params['paging']['Client']['prevPage'] = true; $result = $this->Paginator->prev('<< Previous', null, null, array('class' => 'disabled')); $expected = array( '<span', 'a' => array('href' => '/index/page:1', 'class' => 'prev'), '&lt;&lt; Previous', '/a', '/span' ); $this->assertTags($result, $expected); $result = $this->Paginator->next('Next'); $expected = array( '<span', 'a' => array('href' => '/index/page:3', 'class' => 'next'), 'Next', '/a', '/span' ); $this->assertTags($result, $expected); $result = $this->Paginator->next('Next', array('tag' => 'li')); $expected = array( '<li', 'a' => array('href' => '/index/page:3', 'class' => 'next'), 'Next', '/a', '/li' ); $this->assertTags($result, $expected); $result = $this->Paginator->prev('<< Previous', array('escape' => true)); $expected = array( '<span', 'a' => array('href' => '/index/page:1', 'class' => 'prev'), '&lt;&lt; Previous', '/a', '/span' ); $this->assertTags($result, $expected); $result = $this->Paginator->prev('<< Previous', array('escape' => false)); $expected = array( '<span', 'a' => array('href' => '/index/page:1', 'class' => 'prev'), 'preg:/<< Previous/', '/a', '/span' ); $this->assertTags($result, $expected); $this->Paginator->params['paging'] = array('Client' => array( 'page' => 1, 'current' => 1, 'count' => 13, 'prevPage' => false, 'nextPage' => true, 'pageCount' => 5, 'defaults' => array(), 'options' => array('page' => 1, 'limit' => 3, 'order' => array('Client.name' => 'DESC'), 'conditions' => array())) ); $result = $this->Paginator->prev('<< Previous', null, '<strong>Disabled</strong>'); $expected = array( 'span' => array('class' => 'prev'), '&lt;strong&gt;Disabled&lt;/strong&gt;', '/span' ); $this->assertTags($result, $expected); $result = $this->Paginator->prev('<< Previous', null, '<strong>Disabled</strong>', array('escape' => true)); $expected = array( 'span' => array('class' => 'prev'), '&lt;strong&gt;Disabled&lt;/strong&gt;', '/span' ); $this->assertTags($result, $expected); $result = $this->Paginator->prev('<< Previous', null, '<strong>Disabled</strong>', array('escape' => false)); $expected = array( 'span' => array('class' => 'prev'), '<strong', 'Disabled', '/strong', '/span' ); $this->assertTags($result, $expected); $this->Paginator->params['paging'] = array('Client' => array( 'page' => 1, 'current' => 3, 'count' => 13, 'prevPage' => false, 'nextPage' => true, 'pageCount' => 5, 'defaults' => array(), 'options' => array('page' => 1, 'limit' => 3, 'order' => array('Client.name' => 'DESC'), 'conditions' => array())) ); $this->Paginator->params['paging']['Client']['page'] = 2; $this->Paginator->params['paging']['Client']['prevPage'] = true; $result = $this->Paginator->prev('<< Previous', null, null, array('class' => 'disabled')); $expected = array( '<span', 'a' => array('href' => '/index/page:1/limit:3/sort:Client.name/direction:DESC', 'class' => 'prev'), '&lt;&lt; Previous', '/a', '/span' ); $this->assertTags($result, $expected, true); $result = $this->Paginator->next('Next'); $expected = array( '<span', 'a' => array('href' => '/index/page:3/limit:3/sort:Client.name/direction:DESC', 'class' => 'next'), 'Next', '/a', '/span' ); $this->assertTags($result, $expected); $this->Paginator->params['paging'] = array('Client' => array( 'page' => 2, 'current' => 1, 'count' => 13, 'prevPage' => true, 'nextPage' => false, 'pageCount' => 2, 'defaults' => array(), 'options' => array('page' => 2, 'limit' => 10, 'order' => array(), 'conditions' => array()) )); $result = $this->Paginator->prev('Prev'); $expected = array( '<span', 'a' => array('href' => '/index/page:1/limit:10', 'class' => 'prev'), 'Prev', '/a', '/span' ); $this->assertTags($result, $expected); $this->Paginator->params['paging'] = array( 'Client' => array( 'page' => 2, 'current' => 1, 'count' => 13, 'prevPage' => true, 'nextPage' => false, 'pageCount' => 2, 'defaults' => array(), 'options' => array( 'page' => 2, 'limit' => 10, 'order' => array(), 'conditions' => array() ) ) ); $this->Paginator->options(array('url' => array(12, 'page' => 3))); $result = $this->Paginator->prev('Prev', array('url' => array('foo' => 'bar'))); $expected = array( '<span', 'a' => array('href' => '/index/12/page:1/limit:10/foo:bar', 'class' => 'prev'), 'Prev', '/a', '/span' ); $this->assertTags($result, $expected); }
testPagingLinks method @access public @return void
testPagingLinks
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/paginator.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/paginator.test.php
MIT
function testPagingLinksOptionsReplaceEmptyDisabledOptions() { $this->Paginator->params['paging'] = array( 'Client' => array( 'page' => 1, 'current' => 3, 'count' => 13, 'prevPage' => false, 'nextPage' => true, 'pageCount' => 5, 'defaults' => array( 'limit' => 3, 'step' => 1, 'order' => array('Client.name' => 'DESC'), 'conditions' => array() ), 'options' => array( 'page' => 1, 'limit' => 3, 'order' => array('Client.name' => 'DESC'), 'conditions' => array() ) ) ); $result = $this->Paginator->prev('<< Previous', array('escape' => false)); $expected = array( 'span' => array('class' => 'prev'), 'preg:/<< Previous/', '/span' ); $this->assertTags($result, $expected); $result = $this->Paginator->next('Next >>', array('escape' => false)); $expected = array( '<span', 'a' => array('href' => '/index/page:2', 'class' => 'next'), 'preg:/Next >>/', '/a', '/span' ); $this->assertTags($result, $expected); }
test that __pagingLink methods use $options when $disabledOptions is an empty value. allowing you to use shortcut syntax @return void
testPagingLinksOptionsReplaceEmptyDisabledOptions
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/paginator.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/paginator.test.php
MIT
function testPagingLinksNotDefaultModel() { // Multiple Model Paginate $this->Paginator->params['paging'] = array( 'Client' => array( 'page' => 1, 'current' => 3, 'count' => 13, 'prevPage' => false, 'nextPage' => true, 'pageCount' => 5, 'defaults' => array( 'limit'=>3, 'order' => array('Client.name' => 'DESC')), 'options' => array('page' => 1, 'limit' => 3, 'order' => array('Client.name' => 'DESC'), 'conditions' => array()) ), 'Server' => array( 'page' => 1, 'current' => 1, 'count' => 5, 'prevPage' => false, 'nextPage' => false, 'pageCount' => 5, 'defaults' => array(), 'options' => array('page' => 1, 'limit' => 5, 'order' => array('Server.name' => 'ASC'), 'conditions' => array()) ) ); $result = $this->Paginator->next('Next', array('model' => 'Client')); $expected = array( '<span', 'a' => array('href' => '/index/page:2', 'class' => 'next'), 'Next', '/a', '/span' ); $this->assertTags($result, $expected); $result = $this->Paginator->next('Next', array('model' => 'Server'), 'No Next', array('model' => 'Server')); $expected = array( 'span' => array('class' => 'next'), 'No Next', '/span' ); $this->assertTags($result, $expected); }
testPagingLinksNotDefaultModel Test the creation of paging links when the non default model is used. @access public @return void
testPagingLinksNotDefaultModel
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/paginator.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/paginator.test.php
MIT
function testGenericLinks() { $result = $this->Paginator->link('Sort by title on page 5', array('sort' => 'title', 'page' => 5, 'direction' => 'desc')); $expected = array( 'a' => array('href' => '/index/page:5/sort:title/direction:desc'), 'Sort by title on page 5', '/a' ); $this->assertTags($result, $expected); $this->Paginator->params['paging']['Article']['options']['page'] = 2; $result = $this->Paginator->link('Sort by title', array('sort' => 'title', 'direction' => 'desc')); $expected = array( 'a' => array('href' => '/index/page:2/sort:title/direction:desc'), 'Sort by title', '/a' ); $this->assertTags($result, $expected); $this->Paginator->params['paging']['Article']['options']['page'] = 4; $result = $this->Paginator->link('Sort by title on page 4', array('sort' => 'Article.title', 'direction' => 'desc')); $expected = array( 'a' => array('href' => '/index/page:4/sort:Article.title/direction:desc'), 'Sort by title on page 4', '/a' ); $this->assertTags($result, $expected); }
testGenericLinks method @access public @return void
testGenericLinks
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/paginator.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/paginator.test.php
MIT
function testGenericLinksWithPresetOptions() { $result = $this->Paginator->link('Foo!', array('page' => 1)); $this->assertTags($result, array('a' => array('href' => '/index/page:1'), 'Foo!', '/a')); $this->Paginator->options(array('sort' => 'title', 'direction' => 'desc')); $result = $this->Paginator->link('Foo!', array('page' => 1)); $this->assertTags($result, array( 'a' => array( 'href' => '/index/page:1', 'sort' => 'title', 'direction' => 'desc' ), 'Foo!', '/a' )); $this->Paginator->options(array('sort' => null, 'direction' => null)); $result = $this->Paginator->link('Foo!', array('page' => 1)); $this->assertTags($result, array('a' => array('href' => '/index/page:1'), 'Foo!', '/a')); $this->Paginator->options(array('url' => array( 'sort' => 'title', 'direction' => 'desc' ))); $result = $this->Paginator->link('Foo!', array('page' => 1)); $this->assertTags($result, array( 'a' => array('href' => '/index/page:1/sort:title/direction:desc'), 'Foo!', '/a' )); }
Tests generation of generic links with preset options @access public @return void
testGenericLinksWithPresetOptions
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/paginator.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/paginator.test.php
MIT
function testNumbers() { $this->Paginator->params['paging'] = array('Client' => array( 'page' => 8, 'current' => 3, 'count' => 30, 'prevPage' => false, 'nextPage' => 2, 'pageCount' => 15, 'defaults' => array('limit' => 3, 'step' => 1, 'order' => array('Client.name' => 'DESC'), 'conditions' => array()), 'options' => array('page' => 1, 'limit' => 3, 'order' => array('Client.name' => 'DESC'), 'conditions' => array())) ); $result = $this->Paginator->numbers(); $expected = array( array('span' => array()), array('a' => array('href' => '/index/page:4')), '4', '/a', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/index/page:5')), '5', '/a', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/index/page:6')), '6', '/a', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/index/page:7')), '7', '/a', '/span', ' | ', array('span' => array('class' => 'current')), '8', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/index/page:9')), '9', '/a', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/index/page:10')), '10', '/a', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/index/page:11')), '11', '/a', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/index/page:12')), '12', '/a', '/span', ); $this->assertTags($result, $expected); $result = $this->Paginator->numbers(array('tag' => 'li')); $expected = array( array('li' => array()), array('a' => array('href' => '/index/page:4')), '4', '/a', '/li', ' | ', array('li' => array()), array('a' => array('href' => '/index/page:5')), '5', '/a', '/li', ' | ', array('li' => array()), array('a' => array('href' => '/index/page:6')), '6', '/a', '/li', ' | ', array('li' => array()), array('a' => array('href' => '/index/page:7')), '7', '/a', '/li', ' | ', array('li' => array('class' => 'current')), '8', '/li', ' | ', array('li' => array()), array('a' => array('href' => '/index/page:9')), '9', '/a', '/li', ' | ', array('li' => array()), array('a' => array('href' => '/index/page:10')), '10', '/a', '/li', ' | ', array('li' => array()), array('a' => array('href' => '/index/page:11')), '11', '/a', '/li', ' | ', array('li' => array()), array('a' => array('href' => '/index/page:12')), '12', '/a', '/li', ); $this->assertTags($result, $expected); $result = $this->Paginator->numbers(array('tag' => 'li', 'separator' => false)); $expected = array( array('li' => array()), array('a' => array('href' => '/index/page:4')), '4', '/a', '/li', array('li' => array()), array('a' => array('href' => '/index/page:5')), '5', '/a', '/li', array('li' => array()), array('a' => array('href' => '/index/page:6')), '6', '/a', '/li', array('li' => array()), array('a' => array('href' => '/index/page:7')), '7', '/a', '/li', array('li' => array('class' => 'current')), '8', '/li', array('li' => array()), array('a' => array('href' => '/index/page:9')), '9', '/a', '/li', array('li' => array()), array('a' => array('href' => '/index/page:10')), '10', '/a', '/li', array('li' => array()), array('a' => array('href' => '/index/page:11')), '11', '/a', '/li', array('li' => array()), array('a' => array('href' => '/index/page:12')), '12', '/a', '/li', ); $this->assertTags($result, $expected); $result = $this->Paginator->numbers(true); $expected = array( array('span' => array()), array('a' => array('href' => '/index/page:1')), 'first', '/a', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/index/page:4')), '4', '/a', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/index/page:5')), '5', '/a', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/index/page:6')), '6', '/a', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/index/page:7')), '7', '/a', '/span', ' | ', array('span' => array('class' => 'current')), '8', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/index/page:9')), '9', '/a', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/index/page:10')), '10', '/a', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/index/page:11')), '11', '/a', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/index/page:12')), '12', '/a', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/index/page:15')), 'last', '/a', '/span', ); $this->assertTags($result, $expected); $this->Paginator->params['paging'] = array('Client' => array( 'page' => 1, 'current' => 3, 'count' => 30, 'prevPage' => false, 'nextPage' => 2, 'pageCount' => 15, 'defaults' => array('limit' => 3, 'step' => 1, 'order' => array('Client.name' => 'DESC'), 'conditions' => array()), 'options' => array('page' => 1, 'limit' => 3, 'order' => array('Client.name' => 'DESC'), 'conditions' => array())) ); $result = $this->Paginator->numbers(); $expected = array( array('span' => array('class' => 'current')), '1', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/index/page:2')), '2', '/a', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/index/page:3')), '3', '/a', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/index/page:4')), '4', '/a', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/index/page:5')), '5', '/a', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/index/page:6')), '6', '/a', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/index/page:7')), '7', '/a', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/index/page:8')), '8', '/a', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/index/page:9')), '9', '/a', '/span', ); $this->assertTags($result, $expected); $this->Paginator->params['paging'] = array('Client' => array( 'page' => 14, 'current' => 3, 'count' => 30, 'prevPage' => false, 'nextPage' => 2, 'pageCount' => 15, 'defaults' => array('limit' => 3, 'step' => 1, 'order' => array('Client.name' => 'DESC'), 'conditions' => array()), 'options' => array('page' => 1, 'limit' => 3, 'order' => array('Client.name' => 'DESC'), 'conditions' => array())) ); $result = $this->Paginator->numbers(); $expected = array( array('span' => array()), array('a' => array('href' => '/index/page:7')), '7', '/a', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/index/page:8')), '8', '/a', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/index/page:9')), '9', '/a', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/index/page:10')), '10', '/a', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/index/page:11')), '11', '/a', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/index/page:12')), '12', '/a', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/index/page:13')), '13', '/a', '/span', ' | ', array('span' => array('class' => 'current')), '14', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/index/page:15')), '15', '/a', '/span', ); $this->assertTags($result, $expected); $this->Paginator->params['paging'] = array('Client' => array( 'page' => 2, 'current' => 3, 'count' => 27, 'prevPage' => false, 'nextPage' => 2, 'pageCount' => 9, 'defaults' => array('limit' => 3, 'step' => 1, 'order' => array('Client.name' => 'DESC'), 'conditions' => array()), 'options' => array('page' => 1, 'limit' => 3, 'order' => array('Client.name' => 'DESC'), 'conditions' => array())) ); $result = $this->Paginator->numbers(array('first' => 1)); $expected = array( array('span' => array()), array('a' => array('href' => '/index/page:1')), '1', '/a', '/span', ' | ', array('span' => array('class' => 'current')), '2', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/index/page:3')), '3', '/a', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/index/page:4')), '4', '/a', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/index/page:5')), '5', '/a', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/index/page:6')), '6', '/a', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/index/page:7')), '7', '/a', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/index/page:8')), '8', '/a', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/index/page:9')), '9', '/a', '/span', ); $this->assertTags($result, $expected); $result = $this->Paginator->numbers(array('last' => 1)); $expected = array( array('span' => array()), array('a' => array('href' => '/index/page:1')), '1', '/a', '/span', ' | ', array('span' => array('class' => 'current')), '2', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/index/page:3')), '3', '/a', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/index/page:4')), '4', '/a', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/index/page:5')), '5', '/a', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/index/page:6')), '6', '/a', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/index/page:7')), '7', '/a', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/index/page:8')), '8', '/a', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/index/page:9')), '9', '/a', '/span', ); $this->assertTags($result, $expected); $this->Paginator->params['paging'] = array('Client' => array( 'page' => 15, 'current' => 3, 'count' => 30, 'prevPage' => false, 'nextPage' => 2, 'pageCount' => 15, 'defaults' => array('limit' => 3, 'step' => 1, 'order' => array('Client.name' => 'DESC'), 'conditions' => array()), 'options' => array('page' => 1, 'limit' => 3, 'order' => array('Client.name' => 'DESC'), 'conditions' => array())) ); $result = $this->Paginator->numbers(array('first' => 1)); $expected = array( array('span' => array()), array('a' => array('href' => '/index/page:1')), '1', '/a', '/span', '...', array('span' => array()), array('a' => array('href' => '/index/page:7')), '7', '/a', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/index/page:8')), '8', '/a', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/index/page:9')), '9', '/a', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/index/page:10')), '10', '/a', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/index/page:11')), '11', '/a', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/index/page:12')), '12', '/a', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/index/page:13')), '13', '/a', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/index/page:14')), '14', '/a', '/span', ' | ', array('span' => array('class' => 'current')), '15', '/span', ); $this->assertTags($result, $expected); $this->Paginator->params['paging'] = array('Client' => array( 'page' => 10, 'current' => 3, 'count' => 30, 'prevPage' => false, 'nextPage' => 2, 'pageCount' => 15, 'defaults' => array('limit' => 3, 'step' => 1, 'order' => array('Client.name' => 'DESC'), 'conditions' => array()), 'options' => array('page' => 1, 'limit' => 3, 'order' => array('Client.name' => 'DESC'), 'conditions' => array())) ); $result = $this->Paginator->numbers(array('first' => 1, 'last' => 1)); $expected = array( array('span' => array()), array('a' => array('href' => '/index/page:1')), '1', '/a', '/span', '...', array('span' => array()), array('a' => array('href' => '/index/page:6')), '6', '/a', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/index/page:7')), '7', '/a', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/index/page:8')), '8', '/a', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/index/page:9')), '9', '/a', '/span', ' | ', array('span' => array('class' => 'current')), '10', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/index/page:11')), '11', '/a', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/index/page:12')), '12', '/a', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/index/page:13')), '13', '/a', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/index/page:14')), '14', '/a', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/index/page:15')), '15', '/a', '/span', ); $this->assertTags($result, $expected); $this->Paginator->params['paging'] = array('Client' => array( 'page' => 6, 'current' => 15, 'count' => 623, 'prevPage' => 1, 'nextPage' => 1, 'pageCount' => 42, 'defaults' => array('limit' => 15, 'step' => 1, 'page' => 1, 'order' => array('Client.name' => 'DESC'), 'conditions' => array()), 'options' => array('page' => 6, 'limit' => 15, 'order' => array('Client.name' => 'DESC'), 'conditions' => array())) ); $result = $this->Paginator->numbers(array('first' => 1, 'last' => 1)); $expected = array( array('span' => array()), array('a' => array('href' => '/index/page:1')), '1', '/a', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/index/page:2')), '2', '/a', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/index/page:3')), '3', '/a', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/index/page:4')), '4', '/a', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/index/page:5')), '5', '/a', '/span', ' | ', array('span' => array('class' => 'current')), '6', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/index/page:7')), '7', '/a', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/index/page:8')), '8', '/a', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/index/page:9')), '9', '/a', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/index/page:10')), '10', '/a', '/span', '...', array('span' => array()), array('a' => array('href' => '/index/page:42')), '42', '/a', '/span', ); $this->assertTags($result, $expected); $this->Paginator->params['paging'] = array('Client' => array( 'page' => 37, 'current' => 15, 'count' => 623, 'prevPage' => 1, 'nextPage' => 1, 'pageCount' => 42, 'defaults' => array('limit' => 15, 'step' => 1, 'page' => 1, 'order' => array('Client.name' => 'DESC'), 'conditions' => array()), 'options' => array('page' => 37, 'limit' => 15, 'order' => array('Client.name' => 'DESC'), 'conditions' => array())) ); $result = $this->Paginator->numbers(array('first' => 1, 'last' => 1)); $expected = array( array('span' => array()), array('a' => array('href' => '/index/page:1')), '1', '/a', '/span', '...', array('span' => array()), array('a' => array('href' => '/index/page:33')), '33', '/a', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/index/page:34')), '34', '/a', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/index/page:35')), '35', '/a', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/index/page:36')), '36', '/a', '/span', ' | ', array('span' => array('class' => 'current')), '37', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/index/page:38')), '38', '/a', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/index/page:39')), '39', '/a', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/index/page:40')), '40', '/a', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/index/page:41')), '41', '/a', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/index/page:42')), '42', '/a', '/span', ); $this->assertTags($result, $expected); $this->Paginator->params['paging'] = array( 'Client' => array( 'page' => 1, 'current' => 10, 'count' => 30, 'prevPage' => false, 'nextPage' => 2, 'pageCount' => 3, 'defaults' => array( 'limit' => 3, 'step' => 1, 'order' => array('Client.name' => 'DESC'), 'conditions' => array() ), 'options' => array( 'page' => 1, 'limit' => 3, 'order' => array('Client.name' => 'DESC'), 'conditions' => array() ) ) ); $options = array('modulus' => 10); $result = $this->Paginator->numbers($options); $expected = array( array('span' => array('class' => 'current')), '1', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/index/page:2')), '2', '/a', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/index/page:3')), '3', '/a', '/span', ); $this->assertTags($result, $expected); $this->Paginator->params['paging'] = array('Client' => array( 'page' => 2, 'current' => 10, 'count' => 31, 'prevPage' => true, 'nextPage' => true, 'pageCount' => 4, 'defaults' => array('limit' => 10), 'options' => array('page' => 1, 'order' => array('Client.name' => 'DESC'), 'conditions' => array())) ); $result = $this->Paginator->numbers(); $expected = array( array('span' => array()), array('a' => array('href' => '/index/page:1/sort:Client.name/direction:DESC')), '1', '/a', '/span', ' | ', array('span' => array('class' => 'current')), '2', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/index/page:3/sort:Client.name/direction:DESC')), '3', '/a', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/index/page:4/sort:Client.name/direction:DESC')), '4', '/a', '/span', ); $this->assertTags($result, $expected); $this->Paginator->params['paging'] = array('Client' => array( 'page' => 4895, 'current' => 10, 'count' => 48962, 'prevPage' => 1, 'nextPage' => 1, 'pageCount' => 4897, 'defaults' => array('limit' => 10), 'options' => array('page' => 4894, 'limit' => 10, 'order' => 'Client.name DESC', 'conditions' => array())) ); $result = $this->Paginator->numbers(array('first' => 2, 'modulus' => 2, 'last' => 2)); $expected = array( array('span' => array()), array('a' => array('href' => '/index/page:1')), '1', '/a', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/index/page:2')), '2', '/a', '/span', '...', array('span' => array()), array('a' => array('href' => '/index/page:4894')), '4894', '/a', '/span', ' | ', array('span' => array('class' => 'current')), '4895', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/index/page:4896')), '4896', '/a', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/index/page:4897')), '4897', '/a', '/span', ); $this->assertTags($result, $expected); $this->Paginator->params['paging']['Client']['page'] = 3; $result = $this->Paginator->numbers(array('first' => 2, 'modulus' => 2, 'last' => 2)); $expected = array( array('span' => array()), array('a' => array('href' => '/index/page:1')), '1', '/a', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/index/page:2')), '2', '/a', '/span', ' | ', array('span' => array('class' => 'current')), '3', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/index/page:4')), '4', '/a', '/span', '...', array('span' => array()), array('a' => array('href' => '/index/page:4896')), '4896', '/a', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/index/page:4897')), '4897', '/a', '/span', ); $this->assertTags($result, $expected); $result = $this->Paginator->numbers(array('first' => 2, 'modulus' => 2, 'last' => 2, 'separator' => ' - ')); $expected = array( array('span' => array()), array('a' => array('href' => '/index/page:1')), '1', '/a', '/span', ' - ', array('span' => array()), array('a' => array('href' => '/index/page:2')), '2', '/a', '/span', ' - ', array('span' => array('class' => 'current')), '3', '/span', ' - ', array('span' => array()), array('a' => array('href' => '/index/page:4')), '4', '/a', '/span', '...', array('span' => array()), array('a' => array('href' => '/index/page:4896')), '4896', '/a', '/span', ' - ', array('span' => array()), array('a' => array('href' => '/index/page:4897')), '4897', '/a', '/span', ); $this->assertTags($result, $expected); $result = $this->Paginator->numbers(array('first' => 5, 'modulus' => 5, 'last' => 5, 'separator' => ' - ')); $expected = array( array('span' => array()), array('a' => array('href' => '/index/page:1')), '1', '/a', '/span', ' - ', array('span' => array()), array('a' => array('href' => '/index/page:2')), '2', '/a', '/span', ' - ', array('span' => array('class' => 'current')), '3', '/span', ' - ', array('span' => array()), array('a' => array('href' => '/index/page:4')), '4', '/a', '/span', ' - ', array('span' => array()), array('a' => array('href' => '/index/page:5')), '5', '/a', '/span', ' - ', array('span' => array()), array('a' => array('href' => '/index/page:6')), '6', '/a', '/span', '...', array('span' => array()), array('a' => array('href' => '/index/page:4893')), '4893', '/a', '/span', ' - ', array('span' => array()), array('a' => array('href' => '/index/page:4894')), '4894', '/a', '/span', ' - ', array('span' => array()), array('a' => array('href' => '/index/page:4895')), '4895', '/a', '/span', ' - ', array('span' => array()), array('a' => array('href' => '/index/page:4896')), '4896', '/a', '/span', ' - ', array('span' => array()), array('a' => array('href' => '/index/page:4897')), '4897', '/a', '/span', ); $this->assertTags($result, $expected); $this->Paginator->params['paging']['Client']['page'] = 4893; $result = $this->Paginator->numbers(array('first' => 5, 'modulus' => 4, 'last' => 5, 'separator' => ' - ')); $expected = array( array('span' => array()), array('a' => array('href' => '/index/page:1')), '1', '/a', '/span', ' - ', array('span' => array()), array('a' => array('href' => '/index/page:2')), '2', '/a', '/span', ' - ', array('span' => array()), array('a' => array('href' => '/index/page:3')), '3', '/a', '/span', ' - ', array('span' => array()), array('a' => array('href' => '/index/page:4')), '4', '/a', '/span', ' - ', array('span' => array()), array('a' => array('href' => '/index/page:5')), '5', '/a', '/span', '...', array('span' => array()), array('a' => array('href' => '/index/page:4891')), '4891', '/a', '/span', ' - ', array('span' => array()), array('a' => array('href' => '/index/page:4892')), '4892', '/a', '/span', ' - ', array('span' => array('class' => 'current')), '4893', '/span', ' - ', array('span' => array()), array('a' => array('href' => '/index/page:4894')), '4894', '/a', '/span', ' - ', array('span' => array()), array('a' => array('href' => '/index/page:4895')), '4895', '/a', '/span', ' - ', array('span' => array()), array('a' => array('href' => '/index/page:4896')), '4896', '/a', '/span', ' - ', array('span' => array()), array('a' => array('href' => '/index/page:4897')), '4897', '/a', '/span', ); $this->assertTags($result, $expected); $this->Paginator->params['paging']['Client']['page'] = 58; $result = $this->Paginator->numbers(array('first' => 5, 'modulus' => 4, 'last' => 5, 'separator' => ' - ')); $expected = array( array('span' => array()), array('a' => array('href' => '/index/page:1')), '1', '/a', '/span', ' - ', array('span' => array()), array('a' => array('href' => '/index/page:2')), '2', '/a', '/span', ' - ', array('span' => array()), array('a' => array('href' => '/index/page:3')), '3', '/a', '/span', ' - ', array('span' => array()), array('a' => array('href' => '/index/page:4')), '4', '/a', '/span', ' - ', array('span' => array()), array('a' => array('href' => '/index/page:5')), '5', '/a', '/span', '...', array('span' => array()), array('a' => array('href' => '/index/page:56')), '56', '/a', '/span', ' - ', array('span' => array()), array('a' => array('href' => '/index/page:57')), '57', '/a', '/span', ' - ', array('span' => array('class' => 'current')), '58', '/span', ' - ', array('span' => array()), array('a' => array('href' => '/index/page:59')), '59', '/a', '/span', ' - ', array('span' => array()), array('a' => array('href' => '/index/page:60')), '60', '/a', '/span', '...', array('span' => array()), array('a' => array('href' => '/index/page:4893')), '4893', '/a', '/span', ' - ', array('span' => array()), array('a' => array('href' => '/index/page:4894')), '4894', '/a', '/span', ' - ', array('span' => array()), array('a' => array('href' => '/index/page:4895')), '4895', '/a', '/span', ' - ', array('span' => array()), array('a' => array('href' => '/index/page:4896')), '4896', '/a', '/span', ' - ', array('span' => array()), array('a' => array('href' => '/index/page:4897')), '4897', '/a', '/span', ); $this->assertTags($result, $expected); $this->Paginator->params['paging']['Client']['page'] = 5; $result = $this->Paginator->numbers(array('first' => 5, 'modulus' => 4, 'last' => 5, 'separator' => ' - ')); $expected = array( array('span' => array()), array('a' => array('href' => '/index/page:1')), '1', '/a', '/span', ' - ', array('span' => array()), array('a' => array('href' => '/index/page:2')), '2', '/a', '/span', ' - ', array('span' => array()), array('a' => array('href' => '/index/page:3')), '3', '/a', '/span', ' - ', array('span' => array()), array('a' => array('href' => '/index/page:4')), '4', '/a', '/span', ' - ', array('span' => array('class' => 'current')), '5', '/span', ' - ', array('span' => array()), array('a' => array('href' => '/index/page:6')), '6', '/a', '/span', ' - ', array('span' => array()), array('a' => array('href' => '/index/page:7')), '7', '/a', '/span', '...', array('span' => array()), array('a' => array('href' => '/index/page:4893')), '4893', '/a', '/span', ' - ', array('span' => array()), array('a' => array('href' => '/index/page:4894')), '4894', '/a', '/span', ' - ', array('span' => array()), array('a' => array('href' => '/index/page:4895')), '4895', '/a', '/span', ' - ', array('span' => array()), array('a' => array('href' => '/index/page:4896')), '4896', '/a', '/span', ' - ', array('span' => array()), array('a' => array('href' => '/index/page:4897')), '4897', '/a', '/span', ); $this->assertTags($result, $expected); }
testNumbers method @access public @return void
testNumbers
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/paginator.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/paginator.test.php
MIT
function testFirstAndLast() { $this->Paginator->params['paging'] = array('Client' => array( 'page' => 1, 'current' => 3, 'count' => 30, 'prevPage' => false, 'nextPage' => 2, 'pageCount' => 15, 'defaults' => array('limit' => 3, 'step' => 1, 'order' => array('Client.name' => 'DESC'), 'conditions' => array()), 'options' => array('page' => 1, 'limit' => 3, 'order' => array('Client.name' => 'DESC'), 'conditions' => array())) ); $result = $this->Paginator->first(); $expected = ''; $this->assertEqual($result, $expected); $this->Paginator->params['paging'] = array('Client' => array( 'page' => 4, 'current' => 3, 'count' => 30, 'prevPage' => false, 'nextPage' => 2, 'pageCount' => 15, 'defaults' => array('limit' => 3, 'step' => 1, 'order' => array('Client.name' => 'DESC'), 'conditions' => array()), 'options' => array('page' => 1, 'limit' => 3, 'order' => array('Client.name' => 'DESC'), 'conditions' => array())) ); $result = $this->Paginator->first(); $expected = array( '<span', 'a' => array('href' => '/index/page:1'), '&lt;&lt; first', '/a', '/span' ); $this->assertTags($result, $expected); $result = $this->Paginator->first('<<', array('tag' => 'li')); $expected = array( '<li', 'a' => array('href' => '/index/page:1'), '&lt;&lt;', '/a', '/li' ); $this->assertTags($result, $expected); $result = $this->Paginator->last(); $expected = array( '<span', 'a' => array('href' => '/index/page:15'), 'last &gt;&gt;', '/a', '/span' ); $this->assertTags($result, $expected); $result = $this->Paginator->last(1); $expected = array( '...', '<span', 'a' => array('href' => '/index/page:15'), '15', '/a', '/span' ); $this->assertTags($result, $expected); $result = $this->Paginator->last(2); $expected = array( '...', '<span', array('a' => array('href' => '/index/page:14')), '14', '/a', '/span', ' | ', '<span', array('a' => array('href' => '/index/page:15')), '15', '/a', '/span', ); $this->assertTags($result, $expected); $result = $this->Paginator->last(2, array('tag' => 'li')); $expected = array( '...', '<li', array('a' => array('href' => '/index/page:14')), '14', '/a', '/li', ' | ', '<li', array('a' => array('href' => '/index/page:15')), '15', '/a', '/li', ); $this->assertTags($result, $expected); $this->Paginator->params['paging'] = array('Client' => array( 'page' => 15, 'current' => 3, 'count' => 30, 'prevPage' => false, 'nextPage' => 2, 'pageCount' => 15, 'defaults' => array('limit' => 3, 'step' => 1, 'order' => array('Client.name' => 'DESC'), 'conditions' => array()), 'options' => array('page' => 1, 'limit' => 3, 'order' => array('Client.name' => 'DESC'), 'conditions' => array())) ); $result = $this->Paginator->last(); $expected = ''; $this->assertEqual($result, $expected); $this->Paginator->params['paging'] = array('Client' => array( 'page' => 4, 'current' => 3, 'count' => 30, 'prevPage' => false, 'nextPage' => 2, 'pageCount' => 15, 'defaults' => array('limit' => 3), 'options' => array('page' => 1, 'limit' => 3, 'order' => array('Client.name' => 'DESC'), 'conditions' => array())) ); $result = $this->Paginator->first(); $expected = array( '<span', array('a' => array('href' => '/index/page:1/sort:Client.name/direction:DESC')), '&lt;&lt; first', '/a', '/span', ); $this->assertTags($result, $expected); $result = $this->Paginator->last(); $expected = array( '<span', array('a' => array('href' => '/index/page:15/sort:Client.name/direction:DESC')), 'last &gt;&gt;', '/a', '/span', ); $this->assertTags($result, $expected); $result = $this->Paginator->last(1); $expected = array( '...', '<span', array('a' => array('href' => '/index/page:15/sort:Client.name/direction:DESC')), '15', '/a', '/span', ); $this->assertTags($result, $expected); $result = $this->Paginator->last(2); $expected = array( '...', '<span', array('a' => array('href' => '/index/page:14/sort:Client.name/direction:DESC')), '14', '/a', '/span', ' | ', '<span', array('a' => array('href' => '/index/page:15/sort:Client.name/direction:DESC')), '15', '/a', '/span', ); $this->assertTags($result, $expected); $this->Paginator->options(array('url' => array('full_base' => true))); $result = $this->Paginator->first(); $expected = array( '<span', array('a' => array('href' => FULL_BASE_URL . '/index/page:1/sort:Client.name/direction:DESC')), '&lt;&lt; first', '/a', '/span', ); $this->assertTags($result, $expected); }
testFirstAndLast method @access public @return void
testFirstAndLast
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/paginator.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/paginator.test.php
MIT
function testCounter() { $this->Paginator->params['paging'] = array( 'Client' => array( 'page' => 1, 'current' => 3, 'count' => 13, 'prevPage' => false, 'nextPage' => true, 'pageCount' => 5, 'defaults' => array( 'limit' => 3, 'step' => 1, 'order' => array('Client.name' => 'DESC'), 'conditions' => array() ), 'options' => array( 'page' => 1, 'limit' => 3, 'order' => array('Client.name' => 'DESC'), 'conditions' => array(), 'separator' => 'of' ), ) ); $input = 'Page %page% of %pages%, showing %current% records out of %count% total, '; $input .= 'starting on record %start%, ending on %end%'; $result = $this->Paginator->counter($input); $expected = 'Page 1 of 5, showing 3 records out of 13 total, starting on record 1, '; $expected .= 'ending on 3'; $this->assertEqual($result, $expected); $input = 'Page {:page} of {:pages}, showing {:current} records out of {:count} total, '; $input .= 'starting on record {:start}, ending on {:end}'; $result = $this->Paginator->counter($input); $this->assertEqual($result, $expected); $input = 'Page %page% of %pages%'; $result = $this->Paginator->counter($input); $expected = 'Page 1 of 5'; $this->assertEqual($result, $expected); $result = $this->Paginator->counter(array('format' => $input)); $expected = 'Page 1 of 5'; $this->assertEqual($result, $expected); $result = $this->Paginator->counter(array('format' => 'pages')); $expected = '1 of 5'; $this->assertEqual($result, $expected); $result = $this->Paginator->counter(array('format' => 'range')); $expected = '1 - 3 of 13'; $this->assertEqual($result, $expected); }
testCounter method @access public @return void
testCounter
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/paginator.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/paginator.test.php
MIT
function testHasPage() { $result = $this->Paginator->hasPage('Article', 15); $this->assertFalse($result); $result = $this->Paginator->hasPage('UndefinedModel', 2); $this->assertFalse($result); $result = $this->Paginator->hasPage('Article', 2); $this->assertTrue($result); $result = $this->Paginator->hasPage(2); $this->assertTrue($result); }
testHasPage method @access public @return void
testHasPage
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/paginator.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/paginator.test.php
MIT
function testWithPlugin() { Router::reload(); Router::setRequestInfo(array( array( 'pass' => array(), 'named' => array(), 'prefix' => null, 'form' => array(), 'controller' => 'magazines', 'plugin' => 'my_plugin', 'action' => 'index', 'url' => array('ext' => 'html', 'url' => 'my_plugin/magazines')), array('base' => '', 'here' => '/my_plugin/magazines', 'webroot' => '/') )); $result = $this->Paginator->link('Page 3', array('page' => 3)); $expected = array( 'a' => array('href' => '/my_plugin/magazines/index/page:3'), 'Page 3', '/a' ); $this->assertTags($result, $expected); $this->Paginator->options(array('url' => array('action' => 'another_index'))); $result = $this->Paginator->link('Page 3', array('page' => 3)); $expected = array( 'a' => array('href' => '/my_plugin/magazines/another_index/page:3'), 'Page 3', '/a' ); $this->assertTags($result, $expected); $this->Paginator->options(array('url' => array('controller' => 'issues'))); $result = $this->Paginator->link('Page 3', array('page' => 3)); $expected = array( 'a' => array('href' => '/my_plugin/issues/index/page:3'), 'Page 3', '/a' ); $this->assertTags($result, $expected); $this->Paginator->options(array('url' => array('plugin' => null))); $result = $this->Paginator->link('Page 3', array('page' => 3)); $expected = array( 'a' => array('/magazines/index/page:3'), 'Page 3', '/a' ); $this->Paginator->options(array('url' => array('plugin' => null, 'controller' => 'issues'))); $result = $this->Paginator->link('Page 3', array('page' => 3)); $expected = array( 'a' => array('href' => '/issues/index/page:3'), 'Page 3', '/a' ); $this->assertTags($result, $expected); }
testWithPlugin method @access public @return void
testWithPlugin
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/paginator.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/paginator.test.php
MIT
function testNextLinkUsingDotNotation() { Router::reload(); Router::parse('/'); Router::setRequestInfo(array( array('plugin' => null, 'controller' => 'accounts', 'action' => 'index', 'pass' => array(), 'form' => array(), 'url' => array('url' => 'accounts/', 'mod_rewrite' => 'true'), 'bare' => 0), array('plugin' => null, 'controller' => null, 'action' => null, 'base' => '/officespace', 'here' => '/officespace/accounts/', 'webroot' => '/officespace/', 'passedArgs' => array()) )); $this->Paginator->params['paging']['Article']['options']['order'] = array('Article.title' => 'asc'); $this->Paginator->params['paging']['Article']['page'] = 1; $test = array('url'=> array( 'page'=> '1', 'sort'=>'Article.title', 'direction'=>'asc', )); $this->Paginator->options($test); $result = $this->Paginator->next('Next'); $expected = array( '<span', 'a' => array('href' => '/officespace/accounts/index/page:2/sort:Article.title/direction:asc', 'class' => 'next'), 'Next', '/a', '/span', ); $this->assertTags($result, $expected); }
testNextLinkUsingDotNotation method @access public @return void
testNextLinkUsingDotNotation
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/paginator.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/paginator.test.php
MIT
function testMockAjaxProviderClassInjection() { $Paginator =& new PaginatorHelper(array('ajax' => 'PaginatorMockJs')); $Paginator->params['paging'] = array( 'Article' => array( 'current' => 9, 'count' => 62, 'prevPage' => false, 'nextPage' => true, 'pageCount' => 7, 'defaults' => array(), 'options' => array() ) ); $Paginator->PaginatorMockJs =& new PaginatorMockJsHelper(); $Paginator->PaginatorMockJs->expectOnce('link'); $result = $Paginator->link('Page 2', array('page' => 2), array('update' => '#content')); $this->expectError(); $Paginator =& new PaginatorHelper(array('ajax' => 'Form')); }
test that mock classes injected into paginatorHelper are called when using link() @return void
testMockAjaxProviderClassInjection
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/paginator.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/paginator.test.php
MIT
function testDomReady() { $result = $this->Proto->domReady('foo.name = "bar";'); $expected = 'document.observe("dom:loaded", function (event) {foo.name = "bar";});'; $this->assertEqual($result, $expected); }
test dom ready event creation @return void
testDomReady
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/prototype_engine.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/prototype_engine.test.php
MIT
function testSortable() { $this->Proto->get('#myList'); $result = $this->Proto->sortable(array( 'complete' => 'onComplete', 'sort' => 'onSort', 'wrapCallbacks' => false )); $expected = 'var jsSortable = Sortable.create($("myList"), {onChange:onSort, onUpdate:onComplete});'; $this->assertEqual($result, $expected); }
test sortable list generation @return void
testSortable
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/prototype_engine.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/prototype_engine.test.php
MIT
function testDrag() { $this->Proto->get('#element'); $result = $this->Proto->drag(array( 'start' => 'onStart', 'drag' => 'onDrag', 'stop' => 'onStop', 'snapGrid' => array(10, 10), 'wrapCallbacks' => false )); $expected = 'var jsDrag = new Draggable($("element"), {onDrag:onDrag, onEnd:onStop, onStart:onStart, snap:[10,10]});'; $this->assertEqual($result, $expected); $this->Proto->get('div.dragger'); $result = $this->Proto->drag(array( 'start' => 'onStart', 'drag' => 'onDrag', 'stop' => 'onStop', 'snapGrid' => array(10, 10), 'wrapCallbacks' => false )); $expected = '$$("div.dragger").each(function (item, index) {new Draggable(item, {onDrag:onDrag, onEnd:onStop, onStart:onStart, snap:[10,10]});});'; $this->assertEqual($result, $expected); }
test drag() method. Scriptaculous lacks the ability to take an Array of Elements in new Drag() when selection is a multiple type. Iterate over the array. @return void
testDrag
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/prototype_engine.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/prototype_engine.test.php
MIT
function testSlider() { $this->Proto->get('#element'); $result = $this->Proto->slider(array( 'handle' => '#handle', 'direction' => 'horizontal', 'change' => 'onChange', 'complete' => 'onComplete', 'value' => 4, 'wrapCallbacks' => false )); $expected = 'var jsSlider = new Control.Slider($("handle"), $("element"), {axis:"horizontal", onChange:onComplete, onSlide:onChange, sliderValue:4});'; $this->assertEqual($result, $expected); $this->Proto->get('#element'); $result = $this->Proto->slider(array( 'handle' => '#handle', 'change' => 'change();', 'complete' => 'complete();', 'value' => 4, 'min' => 10, 'max' => 100 )); $expected = 'var jsSlider = new Control.Slider($("handle"), $("element"), {onChange:function (value) {complete();}, onSlide:function (value) {change();}, range:$R(10,100), sliderValue:4});'; $this->assertEqual($result, $expected); }
ensure that slider() method behaves properly @return void
testSlider
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/prototype_engine.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/prototype_engine.test.php
MIT
function testSerializeForm() { $this->Proto->get('#element'); $result = $this->Proto->serializeForm(array('isForm' => true)); $expected = '$("element").serialize();'; $this->assertEqual($result, $expected); $result = $this->Proto->serializeForm(array('isForm' => true, 'inline' => true)); $expected = '$("element").serialize()'; $this->assertEqual($result, $expected); $result = $this->Proto->serializeForm(array('isForm' => false)); $expected = '$($("element").form).serialize();'; $this->assertEqual($result, $expected); $result = $this->Proto->serializeForm(array('isForm' => false, 'inline' => true)); $expected = '$($("element").form).serialize()'; $this->assertEqual($result, $expected); }
test the serializeForm implementation. @return void
testSerializeForm
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/prototype_engine.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/prototype_engine.test.php
MIT
function setUp() { $this->Rss =& new RssHelper(); $this->Rss->Time =& new TimeHelper(); $this->Rss->beforeRender(); $manager =& XmlManager::getInstance(); $manager->namespaces = array(); }
setUp method @access public @return void
setUp
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/rss.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/rss.test.php
MIT
function testAddNamespace() { $this->Rss->addNs('custom', 'http://example.com/dtd.xml'); $manager =& XmlManager::getInstance(); $expected = array('custom' => 'http://example.com/dtd.xml'); $this->assertEqual($manager->namespaces, $expected); $this->Rss->removeNs('custom'); $this->Rss->addNs('dummy', 'http://dummy.com/1.0/'); $result = $this->Rss->document(); $expected = array( 'rss' => array( 'xmlns:dummy' => 'http://dummy.com/1.0/', 'version' => '2.0' ) ); $this->assertTags($result, $expected); $this->Rss->removeNs('dummy'); }
testAddNamespace method @access public @return void
testAddNamespace
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/rss.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/rss.test.php
MIT
function testRemoveNamespace() { $this->Rss->addNs('custom', 'http://example.com/dtd.xml'); $this->Rss->addNs('custom2', 'http://example.com/dtd2.xml'); $manager =& XmlManager::getInstance(); $expected = array('custom' => 'http://example.com/dtd.xml', 'custom2' => 'http://example.com/dtd2.xml'); $this->assertEqual($manager->namespaces, $expected); $this->Rss->removeNs('custom'); $expected = array('custom2' => 'http://example.com/dtd2.xml'); $this->assertEqual($manager->namespaces, $expected); }
testRemoveNamespace method @access public @return void
testRemoveNamespace
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/rss.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/rss.test.php
MIT
function testDocument() { $result = $this->Rss->document(); $expected = array( 'rss' => array( 'version' => '2.0' ) ); $this->assertTags($result, $expected); $result = $this->Rss->document(array('contrived' => 'parameter')); $expected = array( 'rss' => array( 'version' => '2.0' ), '<parameter' ); $this->assertTags($result, $expected); $result = $this->Rss->document(null, 'content'); $expected = array( 'rss' => array( 'version' => '2.0' ), 'content' ); $this->assertTags($result, $expected); $result = $this->Rss->document(array('contrived' => 'parameter'), 'content'); $expected = array( 'rss' => array( 'contrived' => 'parameter', 'version' => '2.0' ), 'content' ); $this->assertTags($result, $expected); }
testDocument method @access public @return void
testDocument
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/rss.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/rss.test.php
MIT
function testChannel() { $attrib = array('a' => '1', 'b' => '2'); $elements = array('title' => 'title'); $content = 'content'; $result = $this->Rss->channel($attrib, $elements, $content); $expected = array( 'channel' => array( 'a' => '1', 'b' => '2' ), '<title', 'title', '/title', '<link', RssHelper::url('/', true), '/link', '<description', 'content', '/channel' ); $this->assertTags($result, $expected); }
testChannel method @access public @return void
testChannel
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/rss.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/rss.test.php
MIT
function testChannelElements() { $attrib = array(); $elements = array( 'title' => 'Title of RSS Feed', 'link' => 'http://example.com', 'description' => 'Description of RSS Feed', 'image' => array( 'title' => 'Title of image', 'url' => 'http://example.com/example.png', 'link' => 'http://example.com' ), 'cloud' => array( 'domain' => "rpc.sys.com", 'port' => "80", 'path' =>"/RPC2", 'registerProcedure' => "myCloud.rssPleaseNotify", 'protocol' => "xml-rpc" ) ); $content = 'content-here'; $result = $this->Rss->channel($attrib, $elements, $content); $expected = array( '<channel', '<title', 'Title of RSS Feed', '/title', '<link', 'http://example.com', '/link', '<description', 'Description of RSS Feed', '/description', '<image', '<title', 'Title of image', '/title', '<url', 'http://example.com/example.png', '/url', '<link', 'http://example.com', '/link', '/image', 'cloud' => array( 'domain' => "rpc.sys.com", 'port' => "80", 'path' =>"/RPC2", 'registerProcedure' => "myCloud.rssPleaseNotify", 'protocol' => "xml-rpc" ), 'content-here', '/channel', ); $this->assertTags($result, $expected); }
test correct creation of channel sub elements. @access public @return void
testChannelElements
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/rss.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/rss.test.php
MIT
function testItems() { $items = array( array('title' => 'title1', 'guid' => 'http://www.example.com/guid1', 'link' => 'http://www.example.com/link1', 'description' => 'description1'), array('title' => 'title2', 'guid' => 'http://www.example.com/guid2', 'link' => 'http://www.example.com/link2', 'description' => 'description2'), array('title' => 'title3', 'guid' => 'http://www.example.com/guid3', 'link' => 'http://www.example.com/link3', 'description' => 'description3') ); $result = $this->Rss->items($items); $expected = array( '<item', '<title', 'title1', '/title', '<guid', 'http://www.example.com/guid1', '/guid', '<link', 'http://www.example.com/link1', '/link', '<description', 'description1', '/description', '/item', '<item', '<title', 'title2', '/title', '<guid', 'http://www.example.com/guid2', '/guid', '<link', 'http://www.example.com/link2', '/link', '<description', 'description2', '/description', '/item', '<item', '<title', 'title3', '/title', '<guid', 'http://www.example.com/guid3', '/guid', '<link', 'http://www.example.com/link3', '/link', '<description', 'description3', '/description', '/item' ); $this->assertTags($result, $expected); $result = $this->Rss->items(array()); $expected = ''; $this->assertEqual($result, $expected); }
testItems method @access public @return void
testItems
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/rss.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/rss.test.php
MIT
function testItem() { $item = array( 'title' => 'My title', 'description' => 'My description', 'link' => 'http://www.google.com/' ); $result = $this->Rss->item(null, $item); $expected = array( '<item', '<title', 'My title', '/title', '<description', 'My description', '/description', '<link', 'http://www.google.com/', '/link', '<guid', 'http://www.google.com/', '/guid', '/item' ); $this->assertTags($result, $expected); $item = array( 'title' => array( 'value' => 'My Title', 'cdata' => true, ), 'link' => 'http://www.example.com/1', 'description' => array( 'value' => 'descriptive words', 'cdata' => true, ), 'pubDate' => '2008-05-31 12:00:00', 'guid' => 'http://www.example.com/1' ); $result = $this->Rss->item(null, $item); $expected = array( '<item', '<title', '<![CDATA[My Title]]', '/title', '<link', 'http://www.example.com/1', '/link', '<description', '<![CDATA[descriptive words]]', '/description', '<pubDate', date('r', strtotime('2008-05-31 12:00:00')), '/pubDate', '<guid', 'http://www.example.com/1', '/guid', '/item' ); $this->assertTags($result, $expected); $item = array( 'title' => array( 'value' => 'My Title & more', 'cdata' => true ) ); $result = $this->Rss->item(null, $item); $expected = array( '<item', '<title', '<![CDATA[My Title &amp; more]]', '/title', '/item' ); $this->assertTags($result, $expected); $item = array( 'title' => array( 'value' => 'My Title & more', 'convertEntities' => false ) ); $result = $this->Rss->item(null, $item); $expected = array( '<item', '<title', 'My Title & more', '/title', '/item' ); $this->assertTags($result, $expected); $item = array( 'title' => array( 'value' => 'My Title & more', 'cdata' => true, 'convertEntities' => false, ) ); $result = $this->Rss->item(null, $item); $expected = array( '<item', '<title', '<![CDATA[My Title & more]]', '/title', '/item' ); $this->assertTags($result, $expected); $item = array( 'category' => array( 'value' => 'CakePHP', 'cdata' => true, 'domain' => 'http://www.cakephp.org' ) ); $result = $this->Rss->item(null, $item); $expected = array( '<item', 'category' => array('domain' => 'http://www.cakephp.org'), '<![CDATA[CakePHP]]', '/category', '/item' ); $this->assertTags($result, $expected); $item = array( 'category' => array( array( 'value' => 'CakePHP', 'cdata' => true, 'domain' => 'http://www.cakephp.org' ), array( 'value' => 'Bakery', 'cdata' => true ) ) ); $result = $this->Rss->item(null, $item); $expected = array( '<item', 'category' => array('domain' => 'http://www.cakephp.org'), '<![CDATA[CakePHP]]', '/category', '<category', '<![CDATA[Bakery]]', '/category', '/item' ); $this->assertTags($result, $expected); $item = array( 'title' => array( 'value' => 'My Title', 'cdata' => true, ), 'link' => 'http://www.example.com/1', 'description' => array( 'value' => 'descriptive words', 'cdata' => true, ), 'enclosure' => array( 'url' => '/test.flv' ), 'pubDate' => '2008-05-31 12:00:00', 'guid' => 'http://www.example.com/1', 'category' => array( array( 'value' => 'CakePHP', 'cdata' => true, 'domain' => 'http://www.cakephp.org' ), array( 'value' => 'Bakery', 'cdata' => true ) ) ); $result = $this->Rss->item(null, $item); $expected = array( '<item', '<title', '<![CDATA[My Title]]', '/title', '<link', 'http://www.example.com/1', '/link', '<description', '<![CDATA[descriptive words]]', '/description', 'enclosure' => array('url' => RssHelper::url('/test.flv', true)), '<pubDate', date('r', strtotime('2008-05-31 12:00:00')), '/pubDate', '<guid', 'http://www.example.com/1', '/guid', 'category' => array('domain' => 'http://www.cakephp.org'), '<![CDATA[CakePHP]]', '/category', '<category', '<![CDATA[Bakery]]', '/category', '/item' ); $this->assertTags($result, $expected); $item = array( 'title' => 'Foo bar', 'link' => array( 'url' => 'http://example.com/foo?a=1&b=2', 'convertEntities' => false ), 'description' => array( 'value' => 'descriptive words', 'cdata' => true, ), 'pubDate' => '2008-05-31 12:00:00' ); $result = $this->Rss->item(null, $item); $expected = array( '<item', '<title', 'Foo bar', '/title', '<link', 'http://example.com/foo?a=1&amp;b=2', '/link', '<description', '<![CDATA[descriptive words]]', '/description', '<pubDate', date('r', strtotime('2008-05-31 12:00:00')), '/pubDate', '<guid', 'http://example.com/foo?a=1&amp;b=2', '/guid', '/item' ); $this->assertTags($result, $expected); }
testItem method @access public @return void
testItem
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/rss.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/rss.test.php
MIT
function testElementAttrNotInParent() { $attributes = array( 'title' => 'Some Title', 'link' => 'http://link.com', 'description' => 'description' ); $elements = array('enclosure' => array('url' => 'http://test.com')); $result = $this->Rss->item($attributes, $elements); $expected = array( 'item' => array( 'title' => 'Some Title', 'link' => 'http://link.com', 'description' => 'description' ), 'enclosure' => array( 'url' => 'http://test.com' ), '/item' ); $this->assertTags($result, $expected); }
testElementAttrNotInParent method @access public @return void
testElementAttrNotInParent
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/rss.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/rss.test.php
MIT
function startTest() { $this->Session = new SessionHelper(); $_SESSION = array( 'test' => 'info', 'Message' => array( 'flash' => array( 'element' => 'default', 'params' => array(), 'message' => 'This is a calling' ), 'notification' => array( 'element' => 'session_helper', 'params' => array('title' => 'Notice!', 'name' => 'Alert!'), 'message' => 'This is a test of the emergency broadcasting system', ), 'classy' => array( 'element' => 'default', 'params' => array('class' => 'positive'), 'message' => 'Recorded' ), 'bare' => array( 'element' => null, 'message' => 'Bare message', 'params' => array(), ), ), 'Deeply' => array('nested' => array('key' => 'value')), ); }
setUp method @access public @return void
startTest
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/session.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/session.test.php
MIT
function tearDown() { $_SESSION = array(); unset($this->Session); }
tearDown method @access public @return void
tearDown
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/session.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/session.test.php
MIT
function testConstruct() { $this->assertFalse(empty($this->Session->sessionTime)); $this->assertFalse(empty($this->Session->security)); }
test construction and initial property settings @return void
testConstruct
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/session.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/session.test.php
MIT
function testRead() { $result = $this->Session->read('Deeply.nested.key'); $this->assertEqual($result, 'value'); $result = $this->Session->read('test'); $this->assertEqual($result, 'info'); }
testRead method @access public @return void
testRead
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/session.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/session.test.php
MIT
function testCheck() { $this->assertTrue($this->Session->check('test')); $this->assertTrue($this->Session->check('Message.flash.element')); $this->assertFalse($this->Session->check('Does.not.exist')); $this->assertFalse($this->Session->check('Nope')); }
testCheck method @access public @return void
testCheck
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/session.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/session.test.php
MIT
function testWrite() { $this->expectError(); $this->Session->write('NoWay', 'AccessDenied'); }
testWrite method @access public @return void
testWrite
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/session.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/session.test.php
MIT
function testFlash() { $result = $this->Session->flash('flash', true); $expected = '<div id="flashMessage" class="message">This is a calling</div>'; $this->assertEqual($result, $expected); $this->assertFalse($this->Session->check('Message.flash')); $expected = '<div id="classyMessage" class="positive">Recorded</div>'; $result = $this->Session->flash('classy', true); $this->assertEqual($result, $expected); App::build(array( 'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS) )); $controller = new Controller(); $this->Session->view = new View($controller); $result = $this->Session->flash('notification', true); $result = str_replace("\r\n", "\n", $result); $expected = "<div id=\"notificationLayout\">\n\t<h1>Alert!</h1>\n\t<h3>Notice!</h3>\n\t<p>This is a test of the emergency broadcasting system</p>\n</div>"; $this->assertEqual($result, $expected); $this->assertFalse($this->Session->check('Message.notification')); $result = $this->Session->flash('bare'); $expected = 'Bare message'; $this->assertEqual($result, $expected); $this->assertFalse($this->Session->check('Message.bare')); }
testFlash method @access public @return void
testFlash
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/session.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/session.test.php
MIT
function testID() { $id = session_id(); $result = $this->Session->id(); $this->assertEqual($id, $result); }
testID method @access public @return void
testID
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/session.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/session.test.php
MIT
function testError() { $result = $this->Session->error(); $this->assertFalse($result); $this->Session->read('CauseError'); $result = $this->Session->error(); $expected = "CauseError doesn't exist"; $this->assertEqual($result, $expected); }
testError method @access public @return void
testError
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/session.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/session.test.php
MIT
function testDisabling() { Configure::write('Session.start', false); $this->Session = new SessionHelper(); $this->assertFalse($this->Session->check('test')); $this->assertFalse($this->Session->read('test')); $this->Session->read('CauseError'); $this->assertFalse($this->Session->error()); ob_start(); $this->assertFalse($this->Session->flash('bare')); $result = ob_get_contents(); ob_clean(); $this->assertFalse($result); }
testDisabling method @access public @return void
testDisabling
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/session.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/session.test.php
MIT
function testValid() { //wierd it always ends up false in the test suite //$this->assertFalse($this->Session->valid()); }
testValid method @access public @return void
testValid
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/session.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/session.test.php
MIT
function setUp() { $this->Text = new TextHelper(); }
setUp method @access public @return void
setUp
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/text.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/text.test.php
MIT
function testHighlightHtml() { $text1 = '<p>strongbow isn&rsquo;t real cider</p>'; $text2 = '<p>strongbow <strong>isn&rsquo;t</strong> real cider</p>'; $text3 = '<img src="what-a-strong-mouse.png" alt="What a strong mouse!" />'; $text4 = 'What a strong mouse: <img src="what-a-strong-mouse.png" alt="What a strong mouse!" />'; $options = array('format' => '<b>\1</b>', 'html' => true); $expected = '<p><b>strong</b>bow isn&rsquo;t real cider</p>'; $this->assertEqual($this->Text->highlight($text1, 'strong', $options), $expected); $expected = '<p><b>strong</b>bow <strong>isn&rsquo;t</strong> real cider</p>'; $this->assertEqual($this->Text->highlight($text2, 'strong', $options), $expected); $this->assertEqual($this->Text->highlight($text3, 'strong', $options), $text3); $this->assertEqual($this->Text->highlight($text3, array('strong', 'what'), $options), $text3); $expected = '<b>What</b> a <b>strong</b> mouse: <img src="what-a-strong-mouse.png" alt="What a strong mouse!" />'; $this->assertEqual($this->Text->highlight($text4, array('strong', 'what'), $options), $expected); }
testHighlightHtml method @access public @return void
testHighlightHtml
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/text.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/text.test.php
MIT
function testHighlightMulti() { $text = 'This is a test text'; $phrases = array('This', 'text'); $result = $this->Text->highlight($text, $phrases, array('format' => array('<b>\1</b>', '<em>\1</em>'))); $expected = '<b>This</b> is a test <em>text</em>'; $this->assertEqual($expected, $result); }
testHighlightMulti method @access public @return void
testHighlightMulti
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/text.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/text.test.php
MIT
function testStripLinks() { $text = 'This is a test text'; $expected = 'This is a test text'; $result = $this->Text->stripLinks($text); $this->assertEqual($expected, $result); $text = 'This is a <a href="#">test</a> text'; $expected = 'This is a test text'; $result = $this->Text->stripLinks($text); $this->assertEqual($expected, $result); $text = 'This <strong>is</strong> a <a href="#">test</a> <a href="#">text</a>'; $expected = 'This <strong>is</strong> a test text'; $result = $this->Text->stripLinks($text); $this->assertEqual($expected, $result); $text = 'This <strong>is</strong> a <a href="#">test</a> and <abbr>some</abbr> other <a href="#">text</a>'; $expected = 'This <strong>is</strong> a test and <abbr>some</abbr> other text'; $result = $this->Text->stripLinks($text); $this->assertEqual($expected, $result); }
testStripLinks method @access public @return void
testStripLinks
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/text.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/text.test.php
MIT
function testAutoLink() { $text = 'This is a test text'; $expected = 'This is a test text'; $result = $this->Text->autoLink($text); $this->assertEqual($expected, $result); $text = 'Text with a partial www.cakephp.org URL and [email protected] email address'; $result = $this->Text->autoLink($text); $expected = 'Text with a partial <a href="http://www.cakephp.org">www.cakephp.org</a> URL and <a href="mailto:test@cakephp\.org">test@cakephp\.org</a> email address'; $this->assertPattern('#^' . $expected . '$#', $result); $text = 'This is a test text with URL http://www.cakephp.org'; $expected = 'This is a test text with URL <a href="http://www.cakephp.org">http://www.cakephp.org</a>'; $result = $this->Text->autoLink($text); $this->assertEqual($result, $expected); $text = 'This is a test text with URL http://www.cakephp.org and some more text'; $expected = 'This is a test text with URL <a href="http://www.cakephp.org">http://www.cakephp.org</a> and some more text'; $result = $this->Text->autoLink($text); $this->assertEqual($result, $expected); $text = "This is a test text with URL http://www.cakephp.org\tand some more text"; $expected = "This is a test text with URL <a href=\"http://www.cakephp.org\">http://www.cakephp.org</a>\tand some more text"; $result = $this->Text->autoLink($text); $this->assertEqual($result, $expected); $text = 'This is a test text with URL http://www.cakephp.org(and some more text)'; $expected = 'This is a test text with URL <a href="http://www.cakephp.org">http://www.cakephp.org</a>(and some more text)'; $result = $this->Text->autoLink($text); $this->assertEqual($result, $expected); $text = 'This is a test text with URL http://www.cakephp.org'; $expected = 'This is a test text with URL <a href="http://www.cakephp.org" class="link">http://www.cakephp.org</a>'; $result = $this->Text->autoLink($text, array('class'=>'link')); $this->assertEqual($result, $expected); $text = 'This is a test text with URL http://www.cakephp.org'; $expected = 'This is a test text with URL <a href="http://www.cakephp.org" class="link" id="MyLink">http://www.cakephp.org</a>'; $result = $this->Text->autoLink($text, array('class'=>'link', 'id'=>'MyLink')); $this->assertEqual($result, $expected); }
testAutoLink method @access public @return void
testAutoLink
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/text.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/text.test.php
MIT
function testAutoLinkUrls() { $text = 'This is a test text'; $expected = 'This is a test text'; $result = $this->Text->autoLinkUrls($text); $this->assertEqual($expected, $result); $text = 'This is a test that includes (www.cakephp.org)'; $expected = 'This is a test that includes (<a href="http://www.cakephp.org">www.cakephp.org</a>)'; $result = $this->Text->autoLinkUrls($text); $this->assertEqual($expected, $result); $text = 'Text with a partial www.cakephp.org URL'; $expected = 'Text with a partial <a href="http://www.cakephp.org"\s*>www.cakephp.org</a> URL'; $result = $this->Text->autoLinkUrls($text); $this->assertPattern('#^' . $expected . '$#', $result); $text = 'Text with a partial www.cakephp.org URL'; $expected = 'Text with a partial <a href="http://www.cakephp.org" \s*class="link">www.cakephp.org</a> URL'; $result = $this->Text->autoLinkUrls($text, array('class' => 'link')); $this->assertPattern('#^' . $expected . '$#', $result); $text = 'Text with a partial WWW.cakephp.org URL'; $expected = 'Text with a partial <a href="http://WWW.cakephp.org"\s*>WWW.cakephp.org</a> URL'; $result = $this->Text->autoLinkUrls($text); $this->assertPattern('#^' . $expected . '$#', $result); $text = 'Text with a partial WWW.cakephp.org &copy; URL'; $expected = 'Text with a partial <a href="http://WWW.cakephp.org"\s*>WWW.cakephp.org</a> &copy; URL'; $result = $this->Text->autoLinkUrls($text, array('escape' => false)); $this->assertPattern('#^' . $expected . '$#', $result); $text = 'Text with a url www.cot.ag/cuIb2Q and more'; $expected = 'Text with a url <a href="http://www.cot.ag/cuIb2Q">www.cot.ag/cuIb2Q</a> and more'; $result = $this->Text->autoLinkUrls($text); $this->assertEqual($expected, $result); $text = 'Text with a url http://www.does--not--work.com and more'; $expected = 'Text with a url <a href="http://www.does--not--work.com">http://www.does--not--work.com</a> and more'; $result = $this->Text->autoLinkUrls($text); $this->assertEqual($expected, $result); $text = 'Text with a url http://www.not--work.com and more'; $expected = 'Text with a url <a href="http://www.not--work.com">http://www.not--work.com</a> and more'; $result = $this->Text->autoLinkUrls($text); $this->assertEqual($expected, $result); }
testAutoLinkUrls method @access public @return void
testAutoLinkUrls
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/text.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/text.test.php
MIT
function testAutoLinkEmails() { $text = 'This is a test text'; $expected = 'This is a test text'; $result = $this->Text->autoLinkUrls($text); $this->assertEqual($expected, $result); $text = 'Text with [email protected] address'; $expected = 'Text with <a href="mailto:[email protected]"\s*>[email protected]</a> address'; $result = $this->Text->autoLinkEmails($text); $this->assertPattern('#^' . $expected . '$#', $result); $text = "Text with o'[email protected] address"; $expected = 'Text with <a href="mailto:o&#039;[email protected]">o&#039;[email protected]</a> address'; $result = $this->Text->autoLinkEmails($text); $this->assertEqual($expected, $result); $text = 'Text with [email protected] address'; $expected = 'Text with <a href="mailto:[email protected]" \s*class="link">[email protected]</a> address'; $result = $this->Text->autoLinkEmails($text, array('class' => 'link')); $this->assertPattern('#^' . $expected . '$#', $result); }
testAutoLinkEmails method @access public @return void
testAutoLinkEmails
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/text.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/text.test.php
MIT
function testAutoLinkEmailInvalid() { $result = $this->Text->autoLinkEmails('this is a myaddress@gmx-de test'); $expected = 'this is a myaddress@gmx-de test'; $this->assertEqual($expected, $result); }
test invalid email addresses. @return void
testAutoLinkEmailInvalid
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/text.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/text.test.php
MIT
function testHighlightCaseInsensitivity() { $text = 'This is a Test text'; $expected = 'This is a <b>Test</b> text'; $result = $this->Text->highlight($text, 'test', array('format' => '<b>\1</b>')); $this->assertEqual($expected, $result); $result = $this->Text->highlight($text, array('test'), array('format' => '<b>\1</b>')); $this->assertEqual($expected, $result); }
testHighlightCaseInsensitivity method @access public @return void
testHighlightCaseInsensitivity
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/text.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/text.test.php
MIT
function testExcerpt() { $text = 'This is a phrase with test text to play with'; $expected = '...ase with test text to ...'; $result = $this->Text->excerpt($text, 'test', 9, '...'); $this->assertEqual($expected, $result); $expected = 'This is a...'; $result = $this->Text->excerpt($text, 'not_found', 9, '...'); $this->assertEqual($expected, $result); $expected = 'This is a phras...'; $result = $this->Text->excerpt($text, null, 9, '...'); $this->assertEqual($expected, $result); $expected = $text; $result = $this->Text->excerpt($text, null, 200, '...'); $this->assertEqual($expected, $result); $expected = '...a phrase w...'; $result = $this->Text->excerpt($text, 'phrase', 2, '...'); $this->assertEqual($expected, $result); $phrase = 'This is a phrase with test text'; $expected = $text; $result = $this->Text->excerpt($text, $phrase, 13, '...'); $this->assertEqual($expected, $result); $text = 'aaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbaaaaaaaaaaaaaaaaaaaaaaaa'; $phrase = 'bbbbbbbb'; $result = $this->Text->excerpt($text, $phrase, 10); $expected = '...aaaaaaaaaabbbbbbbbaaaaaaaaaa...'; $this->assertEqual($expected, $result); }
testExcerpt method @access public @return void
testExcerpt
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/text.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/text.test.php
MIT
function testExcerptCaseInsensitivity() { $text = 'This is a phrase with test text to play with'; $expected = '...ase with test text to ...'; $result = $this->Text->excerpt($text, 'TEST', 9, '...'); $this->assertEqual($expected, $result); $expected = 'This is a...'; $result = $this->Text->excerpt($text, 'NOT_FOUND', 9, '...'); $this->assertEqual($expected, $result); }
testExcerptCaseInsensitivity method @access public @return void
testExcerptCaseInsensitivity
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/text.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/text.test.php
MIT
function testListGeneration() { $result = $this->Text->toList(array()); $this->assertEqual($result, ''); $result = $this->Text->toList(array('One')); $this->assertEqual($result, 'One'); $result = $this->Text->toList(array('Larry', 'Curly', 'Moe')); $this->assertEqual($result, 'Larry, Curly and Moe'); $result = $this->Text->toList(array('Dusty', 'Lucky', 'Ned'), 'y'); $this->assertEqual($result, 'Dusty, Lucky y Ned'); $result = $this->Text->toList(array( 1 => 'Dusty', 2 => 'Lucky', 3 => 'Ned'), 'y'); $this->assertEqual($result, 'Dusty, Lucky y Ned'); $result = $this->Text->toList(array( 1 => 'Dusty', 2 => 'Lucky', 3 => 'Ned'), 'and', ' + '); $this->assertEqual($result, 'Dusty + Lucky and Ned'); $result = $this->Text->toList(array( 'name1' => 'Dusty', 'name2' => 'Lucky')); $this->assertEqual($result, 'Dusty and Lucky'); $result = $this->Text->toList(array( 'test_0' => 'banana', 'test_1' => 'apple', 'test_2' => 'lemon')); $this->assertEqual($result, 'banana, apple and lemon'); }
testListGeneration method @access public @return void
testListGeneration
php
Datawalke/Coordino
cake/tests/cases/libs/view/helpers/text.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/text.test.php
MIT