code
stringlengths 31
707k
| docstring
stringlengths 23
14.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 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 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 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 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 = '€100.100.100,00';
$this->assertEqual($expected, $result);
$result = $this->Number->currency($value, 'GBP');
$expected = '£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 = '(€100.100.100,00)';
$this->assertEqual($expected, $result);
$result = $this->Number->currency($value, 'GBP');
$expected = '(£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 = '-€100.100.100,00';
$this->assertEqual($expected, $result);
$result = $this->Number->currency($value, 'GBP', array('negative'=>'-'));
$expected = '-£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 = '€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 = '(€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 = '-€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 = '€0,00';
$this->assertEqual($expected, $result);
$result = $this->Number->currency($value, 'GBP');
$expected = '£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 = '£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 = '&#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 = '£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 = '€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 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'),
'<< Previous',
'/span'
);
$this->assertTags($result, $expected);
$result = $this->Paginator->prev('<< Previous', null, null, array('class' => 'disabled', 'tag' => 'div'));
$expected = array(
'div' => array('class' => 'disabled'),
'<< 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'),
'<< 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'),
'<< 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'),
'<strong>Disabled</strong>',
'/span'
);
$this->assertTags($result, $expected);
$result = $this->Paginator->prev('<< Previous', null, '<strong>Disabled</strong>', array('escape' => true));
$expected = array(
'span' => array('class' => 'prev'),
'<strong>Disabled</strong>',
'/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'),
'<< 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'),
'<< first',
'/a',
'/span'
);
$this->assertTags($result, $expected);
$result = $this->Paginator->first('<<', array('tag' => 'li'));
$expected = array(
'<li',
'a' => array('href' => '/index/page:1'),
'<<',
'/a',
'/li'
);
$this->assertTags($result, $expected);
$result = $this->Paginator->last();
$expected = array(
'<span',
'a' => array('href' => '/index/page:15'),
'last >>',
'/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')), '<< 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 >>', '/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')), '<< 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 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 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 & 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&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&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 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 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 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 testHighlightHtml() {
$text1 = '<p>strongbow isn’t real cider</p>';
$text2 = '<p>strongbow <strong>isn’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’t real cider</p>';
$this->assertEqual($this->Text->highlight($text1, 'strong', $options), $expected);
$expected = '<p><b>strong</b>bow <strong>isn’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 © URL';
$expected = 'Text with a partial <a href="http://WWW.cakephp.org"\s*>WWW.cakephp.org</a> © 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'[email protected]">o'[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
|
function testToQuarter() {
$result = $this->Time->toQuarter('2007-12-25');
$this->assertEqual($result, 4);
$result = $this->Time->toQuarter('2007-9-25');
$this->assertEqual($result, 3);
$result = $this->Time->toQuarter('2007-3-25');
$this->assertEqual($result, 1);
$result = $this->Time->toQuarter('2007-3-25', true);
$this->assertEqual($result, array('2007-01-01', '2007-03-31'));
$result = $this->Time->toQuarter('2007-5-25', true);
$this->assertEqual($result, array('2007-04-01', '2007-06-30'));
$result = $this->Time->toQuarter('2007-8-25', true);
$this->assertEqual($result, array('2007-07-01', '2007-09-30'));
$result = $this->Time->toQuarter('2007-12-25', true);
$this->assertEqual($result, array('2007-10-01', '2007-12-31'));
}
|
testToQuarter method
@access public
@return void
|
testToQuarter
|
php
|
Datawalke/Coordino
|
cake/tests/cases/libs/view/helpers/time.test.php
|
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/time.test.php
|
MIT
|
function testTimeAgoInWords() {
$result = $this->Time->timeAgoInWords(strtotime('+4 months +2 weeks +3 days'), array('end' => '8 years'), true);
$this->assertEqual($result, '4 months, 2 weeks, 3 days');
$result = $this->Time->timeAgoInWords(strtotime('+4 months +2 weeks +2 days'), array('end' => '8 years'), true);
$this->assertEqual($result, '4 months, 2 weeks, 2 days');
$result = $this->Time->timeAgoInWords(strtotime('+4 months +2 weeks +1 day'), array('end' => '8 years'), true);
$this->assertEqual($result, '4 months, 2 weeks, 1 day');
$result = $this->Time->timeAgoInWords(strtotime('+3 months +2 weeks +1 day'), array('end' => '8 years'), true);
$this->assertEqual($result, '3 months, 2 weeks, 1 day');
$result = $this->Time->timeAgoInWords(strtotime('+3 months +2 weeks'), array('end' => '8 years'), true);
$this->assertEqual($result, '3 months, 2 weeks');
$result = $this->Time->timeAgoInWords(strtotime('+3 months +1 week +6 days'), array('end' => '8 years'), true);
$this->assertEqual($result, '3 months, 1 week, 6 days');
$result = $this->Time->timeAgoInWords(strtotime('+2 months +2 weeks +1 day'), array('end' => '8 years'), true);
$this->assertEqual($result, '2 months, 2 weeks, 1 day');
$result = $this->Time->timeAgoInWords(strtotime('+2 months +2 weeks'), array('end' => '8 years'), true);
$this->assertEqual($result, '2 months, 2 weeks');
$result = $this->Time->timeAgoInWords(strtotime('+2 months +1 week +6 days'), array('end' => '8 years'), true);
$this->assertEqual($result, '2 months, 1 week, 6 days');
$result = $this->Time->timeAgoInWords(strtotime('+1 month +1 week +6 days'), array('end' => '8 years'), true);
$this->assertEqual($result, '1 month, 1 week, 6 days');
for($i = 0; $i < 200; $i ++) {
$years = mt_rand(0, 3);
$months = mt_rand(0, 11);
$weeks = mt_rand(0, 3);
$days = mt_rand(0, 6);
$hours = 0;
$minutes = 0;
$seconds = 0;
$relative_date = '';
if ($years > 0) {
// years and months and days
$relative_date .= ($relative_date ? ', -' : '-') . $years . ' year' . ($years > 1 ? 's' : '');
$relative_date .= $months > 0 ? ($relative_date ? ', -' : '-') . $months . ' month' . ($months > 1 ? 's' : '') : '';
$relative_date .= $weeks > 0 ? ($relative_date ? ', -' : '-') . $weeks . ' week' . ($weeks > 1 ? 's' : '') : '';
$relative_date .= $days > 0 ? ($relative_date ? ', -' : '-') . $days . ' day' . ($days > 1 ? 's' : '') : '';
} elseif (abs($months) > 0) {
// months, weeks and days
$relative_date .= ($relative_date ? ', -' : '-') . $months . ' month' . ($months > 1 ? 's' : '');
$relative_date .= $weeks > 0 ? ($relative_date ? ', -' : '-') . $weeks . ' week' . ($weeks > 1 ? 's' : '') : '';
$relative_date .= $days > 0 ? ($relative_date ? ', -' : '-') . $days . ' day' . ($days > 1 ? 's' : '') : '';
} elseif (abs($weeks) > 0) {
// weeks and days
$relative_date .= ($relative_date ? ', -' : '-') . $weeks . ' week' . ($weeks > 1 ? 's' : '');
$relative_date .= $days > 0 ? ($relative_date ? ', -' : '-') . $days . ' day' . ($days > 1 ? 's' : '') : '';
} elseif (abs($days) > 0) {
// days and hours
$relative_date .= ($relative_date ? ', -' : '-') . $days . ' day' . ($days > 1 ? 's' : '');
$relative_date .= $hours > 0 ? ($relative_date ? ', -' : '-') . $hours . ' hour' . ($hours > 1 ? 's' : '') : '';
} elseif (abs($hours) > 0) {
// hours and minutes
$relative_date .= ($relative_date ? ', -' : '-') . $hours . ' hour' . ($hours > 1 ? 's' : '');
$relative_date .= $minutes > 0 ? ($relative_date ? ', -' : '-') . $minutes . ' minute' . ($minutes > 1 ? 's' : '') : '';
} elseif (abs($minutes) > 0) {
// minutes only
$relative_date .= ($relative_date ? ', -' : '-') . $minutes . ' minute' . ($minutes > 1 ? 's' : '');
} else {
// seconds only
$relative_date .= ($relative_date ? ', -' : '-') . $seconds . ' second' . ($seconds != 1 ? 's' : '');
}
if (date('j/n/y', strtotime(str_replace(',','',$relative_date))) != '1/1/70') {
$result = $this->Time->timeAgoInWords(strtotime(str_replace(',','',$relative_date)), array('end' => '8 years'), true);
if ($relative_date == '0 seconds') {
$relative_date = '0 seconds ago';
}
$relative_date = str_replace('-', '', $relative_date) . ' ago';
$this->assertEqual($result, $relative_date);
}
}
for ($i = 0; $i < 200; $i ++) {
$years = mt_rand(0, 3);
$months = mt_rand(0, 11);
$weeks = mt_rand(0, 3);
$days = mt_rand(0, 6);
$hours = 0;
$minutes = 0;
$seconds = 0;
$relative_date = '';
if ($years > 0) {
// years and months and days
$relative_date .= ($relative_date ? ', ' : '') . $years . ' year' . ($years > 1 ? 's' : '');
$relative_date .= $months > 0 ? ($relative_date ? ', ' : '') . $months . ' month' . ($months > 1 ? 's' : '') : '';
$relative_date .= $weeks > 0 ? ($relative_date ? ', ' : '') . $weeks . ' week' . ($weeks > 1 ? 's' : '') : '';
$relative_date .= $days > 0 ? ($relative_date ? ', ' : '') . $days . ' day' . ($days > 1 ? 's' : '') : '';
} elseif (abs($months) > 0) {
// months, weeks and days
$relative_date .= ($relative_date ? ', ' : '') . $months . ' month' . ($months > 1 ? 's' : '');
$relative_date .= $weeks > 0 ? ($relative_date ? ', ' : '') . $weeks . ' week' . ($weeks > 1 ? 's' : '') : '';
$relative_date .= $days > 0 ? ($relative_date ? ', ' : '') . $days . ' day' . ($days > 1 ? 's' : '') : '';
} elseif (abs($weeks) > 0) {
// weeks and days
$relative_date .= ($relative_date ? ', ' : '') . $weeks . ' week' . ($weeks > 1 ? 's' : '');
$relative_date .= $days > 0 ? ($relative_date ? ', ' : '') . $days . ' day' . ($days > 1 ? 's' : '') : '';
} elseif (abs($days) > 0) {
// days and hours
$relative_date .= ($relative_date ? ', ' : '') . $days . ' day' . ($days > 1 ? 's' : '');
$relative_date .= $hours > 0 ? ($relative_date ? ', ' : '') . $hours . ' hour' . ($hours > 1 ? 's' : '') : '';
} elseif (abs($hours) > 0) {
// hours and minutes
$relative_date .= ($relative_date ? ', ' : '') . $hours . ' hour' . ($hours > 1 ? 's' : '');
$relative_date .= $minutes > 0 ? ($relative_date ? ', ' : '') . $minutes . ' minute' . ($minutes > 1 ? 's' : '') : '';
} elseif (abs($minutes) > 0) {
// minutes only
$relative_date .= ($relative_date ? ', ' : '') . $minutes . ' minute' . ($minutes > 1 ? 's' : '');
} else {
// seconds only
$relative_date .= ($relative_date ? ', ' : '') . $seconds . ' second' . ($seconds != 1 ? 's' : '');
}
if (date('j/n/y', strtotime(str_replace(',','',$relative_date))) != '1/1/70') {
$result = $this->Time->timeAgoInWords(strtotime(str_replace(',','',$relative_date)), array('end' => '8 years'), true);
if ($relative_date == '0 seconds') {
$relative_date = '0 seconds ago';
}
$relative_date = str_replace('-', '', $relative_date) . '';
$this->assertEqual($result, $relative_date);
}
}
$result = $this->Time->timeAgoInWords(strtotime('-2 years -5 months -2 days'), array('end' => '3 years'), true);
$this->assertEqual($result, '2 years, 5 months, 2 days ago');
$result = $this->Time->timeAgoInWords('2007-9-25');
$this->assertEqual($result, 'on 25/9/07');
$result = $this->Time->timeAgoInWords('2007-9-25', 'Y-m-d');
$this->assertEqual($result, 'on 2007-09-25');
$result = $this->Time->timeAgoInWords('2007-9-25', 'Y-m-d', true);
$this->assertEqual($result, 'on 2007-09-25');
$result = $this->Time->timeAgoInWords(strtotime('-2 weeks -2 days'), 'Y-m-d', false);
$this->assertEqual($result, '2 weeks, 2 days ago');
$result = $this->Time->timeAgoInWords(strtotime('+2 weeks +2 days'), 'Y-m-d', true);
$this->assertPattern('/^2 weeks, [1|2] day(s)?$/', $result);
$result = $this->Time->timeAgoInWords(strtotime('+2 months +2 days'), array('end' => '1 month'));
$this->assertEqual($result, 'on ' . date('j/n/y', strtotime('+2 months +2 days')));
$result = $this->Time->timeAgoInWords(strtotime('+2 months +2 days'), array('end' => '3 month'));
$this->assertPattern('/2 months/', $result);
$result = $this->Time->timeAgoInWords(strtotime('+2 months +12 days'), array('end' => '3 month'));
$this->assertPattern('/2 months, 1 week/', $result);
$result = $this->Time->timeAgoInWords(strtotime('+3 months +5 days'), array('end' => '4 month'));
$this->assertEqual($result, '3 months, 5 days');
$result = $this->Time->timeAgoInWords(strtotime('-2 months -2 days'), array('end' => '3 month'));
$this->assertEqual($result, '2 months, 2 days ago');
$result = $this->Time->timeAgoInWords(strtotime('-2 months -2 days'), array('end' => '3 month'));
$this->assertEqual($result, '2 months, 2 days ago');
$result = $this->Time->timeAgoInWords(strtotime('+2 months +2 days'), array('end' => '3 month'));
$this->assertPattern('/2 months/', $result);
$result = $this->Time->timeAgoInWords(strtotime('+2 months +2 days'), array('end' => '1 month', 'format' => 'Y-m-d'));
$this->assertEqual($result, 'on ' . date('Y-m-d', strtotime('+2 months +2 days')));
$result = $this->Time->timeAgoInWords(strtotime('-2 months -2 days'), array('end' => '1 month', 'format' => 'Y-m-d'));
$this->assertEqual($result, 'on ' . date('Y-m-d', strtotime('-2 months -2 days')));
$result = $this->Time->timeAgoInWords(strtotime('-13 months -5 days'), array('end' => '2 years'));
$this->assertEqual($result, '1 year, 1 month, 5 days ago');
$fourHours = $this->Time->timeAgoInWords(strtotime('-5 days -2 hours'), array('userOffset' => -4));
$result = $this->Time->timeAgoInWords(strtotime('-5 days -2 hours'), array('userOffset' => 4));
$this->assertEqual($fourHours, $result);
$result = $this->Time->timeAgoInWords(strtotime('-2 hours'));
$expected = '2 hours ago';
$this->assertEqual($expected, $result);
$result = $this->Time->timeAgoInWords(strtotime('-12 minutes'));
$expected = '12 minutes ago';
$this->assertEqual($expected, $result);
$result = $this->Time->timeAgoInWords(strtotime('-12 seconds'));
$expected = '12 seconds ago';
$this->assertEqual($expected, $result);
$time = strtotime('-3 years -12 months');
$result = $this->Time->timeAgoInWords($time);
$expected = 'on ' . date('j/n/y', $time);
$this->assertEqual($expected, $result);
}
|
testTimeAgoInWords method
@access public
@return void
|
testTimeAgoInWords
|
php
|
Datawalke/Coordino
|
cake/tests/cases/libs/view/helpers/time.test.php
|
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/time.test.php
|
MIT
|
function testRelative() {
$result = $this->Time->relativeTime('-1 week');
$this->assertEqual($result, '1 week ago');
$result = $this->Time->relativeTime('+1 week');
$this->assertEqual($result, '1 week');
}
|
testRelative method
@access public
@return void
|
testRelative
|
php
|
Datawalke/Coordino
|
cake/tests/cases/libs/view/helpers/time.test.php
|
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/time.test.php
|
MIT
|
function testNice() {
$time = time() + 2 * DAY;
$this->assertEqual(date('D, M jS Y, H:i', $time), $this->Time->nice($time));
$time = time() - 2 * DAY;
$this->assertEqual(date('D, M jS Y, H:i', $time), $this->Time->nice($time));
$time = time();
$this->assertEqual(date('D, M jS Y, H:i', $time), $this->Time->nice($time));
$time = 0;
$this->assertEqual(date('D, M jS Y, H:i', time()), $this->Time->nice($time));
$time = null;
$this->assertEqual(date('D, M jS Y, H:i', time()), $this->Time->nice($time));
}
|
testNice method
@access public
@return void
|
testNice
|
php
|
Datawalke/Coordino
|
cake/tests/cases/libs/view/helpers/time.test.php
|
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/time.test.php
|
MIT
|
function testNiceShort() {
$time = time() + 2 * DAY;
if (date('Y', $time) == date('Y')) {
$this->assertEqual(date('M jS, H:i', $time), $this->Time->niceShort($time));
} else {
$this->assertEqual(date('M jS Y, H:i', $time), $this->Time->niceShort($time));
}
$time = time();
$this->assertEqual('Today, ' . date('H:i', $time), $this->Time->niceShort($time));
$time = time() - DAY;
$this->assertEqual('Yesterday, ' . date('H:i', $time), $this->Time->niceShort($time));
}
|
testNiceShort method
@access public
@return void
|
testNiceShort
|
php
|
Datawalke/Coordino
|
cake/tests/cases/libs/view/helpers/time.test.php
|
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/time.test.php
|
MIT
|
function testDaysAsSql() {
$begin = time();
$end = time() + DAY;
$field = 'my_field';
$expected = '(my_field >= \''.date('Y-m-d', $begin).' 00:00:00\') AND (my_field <= \''.date('Y-m-d', $end).' 23:59:59\')';
$this->assertEqual($expected, $this->Time->daysAsSql($begin, $end, $field));
}
|
testDaysAsSql method
@access public
@return void
|
testDaysAsSql
|
php
|
Datawalke/Coordino
|
cake/tests/cases/libs/view/helpers/time.test.php
|
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/time.test.php
|
MIT
|
function testDayAsSql() {
$time = time();
$field = 'my_field';
$expected = '(my_field >= \''.date('Y-m-d', $time).' 00:00:00\') AND (my_field <= \''.date('Y-m-d', $time).' 23:59:59\')';
$this->assertEqual($expected, $this->Time->dayAsSql($time, $field));
}
|
testDayAsSql method
@access public
@return void
|
testDayAsSql
|
php
|
Datawalke/Coordino
|
cake/tests/cases/libs/view/helpers/time.test.php
|
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/time.test.php
|
MIT
|
function testToUnix() {
$this->assertEqual(time(), $this->Time->toUnix(time()));
$this->assertEqual(strtotime('+1 day'), $this->Time->toUnix('+1 day'));
$this->assertEqual(strtotime('+0 days'), $this->Time->toUnix('+0 days'));
$this->assertEqual(strtotime('-1 days'), $this->Time->toUnix('-1 days'));
$this->assertEqual(false, $this->Time->toUnix(''));
$this->assertEqual(false, $this->Time->toUnix(null));
}
|
testToUnix method
@access public
@return void
|
testToUnix
|
php
|
Datawalke/Coordino
|
cake/tests/cases/libs/view/helpers/time.test.php
|
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/time.test.php
|
MIT
|
function testToAtom() {
$this->assertEqual(date('Y-m-d\TH:i:s\Z'), $this->Time->toAtom(time()));
}
|
testToAtom method
@access public
@return void
|
testToAtom
|
php
|
Datawalke/Coordino
|
cake/tests/cases/libs/view/helpers/time.test.php
|
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/time.test.php
|
MIT
|
function testToRss() {
$this->assertEqual(date('r'), $this->Time->toRss(time()));
if (!$this->skipIf(!class_exists('DateTimeZone'), '%s DateTimeZone class not available.')) {
$timezones = array('Europe/London', 'Europe/Brussels', 'UTC', 'America/Denver', 'America/Caracas', 'Asia/Kathmandu');
foreach($timezones as $timezone) {
$yourTimezone = new DateTimeZone($timezone);
$yourTime = new DateTime('now', $yourTimezone);
$userOffset = $yourTimezone->getOffset($yourTime) / HOUR;
$this->assertEqual($yourTime->format('r'), $this->Time->toRss(time(), $userOffset));
}
}
}
|
testToRss method
@access public
@return void
|
testToRss
|
php
|
Datawalke/Coordino
|
cake/tests/cases/libs/view/helpers/time.test.php
|
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/time.test.php
|
MIT
|
function testFormat() {
$format = 'D-M-Y';
$arr = array(time(), strtotime('+1 days'), strtotime('+1 days'), strtotime('+0 days'));
foreach ($arr as $val) {
$this->assertEqual(date($format, $val), $this->Time->format($format, $val));
}
$result = $this->Time->format('Y-m-d', null, 'never');
$this->assertEqual($result, 'never');
}
|
testFormat method
@access public
@return void
|
testFormat
|
php
|
Datawalke/Coordino
|
cake/tests/cases/libs/view/helpers/time.test.php
|
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/time.test.php
|
MIT
|
function testGmt() {
$hour = 3;
$min = 4;
$sec = 2;
$month = 5;
$day = 14;
$year = 2007;
$time = mktime($hour, $min, $sec, $month, $day, $year);
$expected = gmmktime($hour, $min, $sec, $month, $day, $year);
$this->assertEqual($expected, $this->Time->gmt(date('Y-n-j G:i:s', $time)));
$hour = date('H');
$min = date('i');
$sec = date('s');
$month = date('m');
$day = date('d');
$year = date('Y');
$expected = gmmktime($hour, $min, $sec, $month, $day, $year);
$this->assertEqual($expected, $this->Time->gmt(null));
}
|
testOfGmt method
@access public
@return void
|
testGmt
|
php
|
Datawalke/Coordino
|
cake/tests/cases/libs/view/helpers/time.test.php
|
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/time.test.php
|
MIT
|
function testIsToday() {
$result = $this->Time->isToday('+1 day');
$this->assertFalse($result);
$result = $this->Time->isToday('+1 days');
$this->assertFalse($result);
$result = $this->Time->isToday('+0 day');
$this->assertTrue($result);
$result = $this->Time->isToday('-1 day');
$this->assertFalse($result);
}
|
testIsToday method
@access public
@return void
|
testIsToday
|
php
|
Datawalke/Coordino
|
cake/tests/cases/libs/view/helpers/time.test.php
|
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/time.test.php
|
MIT
|
function testIsThisWeek() {
// A map of days which goes from -1 day of week to +1 day of week
$map = array(
'Mon' => array(-1, 7), 'Tue' => array(-2, 6), 'Wed' => array(-3, 5),
'Thu' => array(-4, 4), 'Fri' => array(-5, 3), 'Sat' => array(-6, 2),
'Sun' => array(-7, 1)
);
$days = $map[date('D')];
for ($day = $days[0] + 1; $day < $days[1]; $day++) {
$this->assertTrue($this->Time->isThisWeek(($day > 0 ? '+' : '') . $day . ' days'));
}
$this->assertFalse($this->Time->isThisWeek($days[0] . ' days'));
$this->assertFalse($this->Time->isThisWeek('+' . $days[1] . ' days'));
}
|
testIsThisWeek method
@access public
@return void
|
testIsThisWeek
|
php
|
Datawalke/Coordino
|
cake/tests/cases/libs/view/helpers/time.test.php
|
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/time.test.php
|
MIT
|
function testIsThisMonth() {
$result = $this->Time->isThisMonth('+0 day');
$this->assertTrue($result);
$result = $this->Time->isThisMonth($time = mktime(0, 0, 0, date('m'), mt_rand(1, 28), date('Y')));
$this->assertTrue($result);
$result = $this->Time->isThisMonth(mktime(0, 0, 0, date('m'), mt_rand(1, 28), date('Y') - mt_rand(1, 12)));
$this->assertFalse($result);
$result = $this->Time->isThisMonth(mktime(0, 0, 0, date('m'), mt_rand(1, 28), date('Y') + mt_rand(1, 12)));
$this->assertFalse($result);
}
|
testIsThisMonth method
@access public
@return void
|
testIsThisMonth
|
php
|
Datawalke/Coordino
|
cake/tests/cases/libs/view/helpers/time.test.php
|
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/time.test.php
|
MIT
|
function testIsThisYear() {
$result = $this->Time->isThisYear('+0 day');
$this->assertTrue($result);
$result = $this->Time->isThisYear(mktime(0, 0, 0, mt_rand(1, 12), mt_rand(1, 28), date('Y')));
$this->assertTrue($result);
}
|
testIsThisYear method
@access public
@return void
|
testIsThisYear
|
php
|
Datawalke/Coordino
|
cake/tests/cases/libs/view/helpers/time.test.php
|
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/time.test.php
|
MIT
|
function testWasYesterday() {
$result = $this->Time->wasYesterday('+1 day');
$this->assertFalse($result);
$result = $this->Time->wasYesterday('+1 days');
$this->assertFalse($result);
$result = $this->Time->wasYesterday('+0 day');
$this->assertFalse($result);
$result = $this->Time->wasYesterday('-1 day');
$this->assertTrue($result);
$result = $this->Time->wasYesterday('-1 days');
$this->assertTrue($result);
$result = $this->Time->wasYesterday('-2 days');
$this->assertFalse($result);
}
|
testWasYesterday method
@access public
@return void
|
testWasYesterday
|
php
|
Datawalke/Coordino
|
cake/tests/cases/libs/view/helpers/time.test.php
|
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/time.test.php
|
MIT
|
function testIsTomorrow() {
$result = $this->Time->isTomorrow('+1 day');
$this->assertTrue($result);
$result = $this->Time->isTomorrow('+1 days');
$this->assertTrue($result);
$result = $this->Time->isTomorrow('+0 day');
$this->assertFalse($result);
$result = $this->Time->isTomorrow('-1 day');
$this->assertFalse($result);
}
|
testIsTomorrow method
@access public
@return void
|
testIsTomorrow
|
php
|
Datawalke/Coordino
|
cake/tests/cases/libs/view/helpers/time.test.php
|
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/time.test.php
|
MIT
|
function testWasWithinLast() {
$this->assertTrue($this->Time->wasWithinLast('1 day', '-1 day'));
$this->assertTrue($this->Time->wasWithinLast('1 week', '-1 week'));
$this->assertTrue($this->Time->wasWithinLast('1 year', '-1 year'));
$this->assertTrue($this->Time->wasWithinLast('1 second', '-1 second'));
$this->assertTrue($this->Time->wasWithinLast('1 minute', '-1 minute'));
$this->assertTrue($this->Time->wasWithinLast('1 year', '-1 year'));
$this->assertTrue($this->Time->wasWithinLast('1 month', '-1 month'));
$this->assertTrue($this->Time->wasWithinLast('1 day', '-1 day'));
$this->assertTrue($this->Time->wasWithinLast('1 week', '-1 day'));
$this->assertTrue($this->Time->wasWithinLast('2 week', '-1 week'));
$this->assertFalse($this->Time->wasWithinLast('1 second', '-1 year'));
$this->assertTrue($this->Time->wasWithinLast('10 minutes', '-1 second'));
$this->assertTrue($this->Time->wasWithinLast('23 minutes', '-1 minute'));
$this->assertFalse($this->Time->wasWithinLast('0 year', '-1 year'));
$this->assertTrue($this->Time->wasWithinLast('13 month', '-1 month'));
$this->assertTrue($this->Time->wasWithinLast('2 days', '-1 day'));
$this->assertFalse($this->Time->wasWithinLast('1 week', '-2 weeks'));
$this->assertFalse($this->Time->wasWithinLast('1 second', '-2 seconds'));
$this->assertFalse($this->Time->wasWithinLast('1 day', '-2 days'));
$this->assertFalse($this->Time->wasWithinLast('1 hour', '-2 hours'));
$this->assertFalse($this->Time->wasWithinLast('1 month', '-2 months'));
$this->assertFalse($this->Time->wasWithinLast('1 year', '-2 years'));
$this->assertFalse($this->Time->wasWithinLast('1 day', '-2 weeks'));
$this->assertFalse($this->Time->wasWithinLast('1 day', '-2 days'));
$this->assertFalse($this->Time->wasWithinLast('0 days', '-2 days'));
$this->assertTrue($this->Time->wasWithinLast('1 hour', '-20 seconds'));
$this->assertTrue($this->Time->wasWithinLast('1 year', '-60 minutes -30 seconds'));
$this->assertTrue($this->Time->wasWithinLast('3 years', '-2 months'));
$this->assertTrue($this->Time->wasWithinLast('5 months', '-4 months'));
$this->assertTrue($this->Time->wasWithinLast('5 ', '-3 days'));
$this->assertTrue($this->Time->wasWithinLast('1 ', '-1 hour'));
$this->assertTrue($this->Time->wasWithinLast('1 ', '-1 minute'));
$this->assertTrue($this->Time->wasWithinLast('1 ', '-23 hours -59 minutes -59 seconds'));
}
|
testWasWithinLast method
@access public
@return void
|
testWasWithinLast
|
php
|
Datawalke/Coordino
|
cake/tests/cases/libs/view/helpers/time.test.php
|
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/time.test.php
|
MIT
|
function testUserOffset() {
if ($this->skipIf(!class_exists('DateTimeZone'), '%s DateTimeZone class not available.')) {
return;
}
$timezoneServer = new DateTimeZone(date_default_timezone_get());
$timeServer = new DateTime('now', $timezoneServer);
$yourTimezone = $timezoneServer->getOffset($timeServer) / HOUR;
$expected = time();
$result = $this->Time->fromString(time(), $yourTimezone);
$this->assertEqual($result, $expected);
}
|
testUserOffset method
@access public
@return void
|
testUserOffset
|
php
|
Datawalke/Coordino
|
cake/tests/cases/libs/view/helpers/time.test.php
|
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/time.test.php
|
MIT
|
function testFromString() {
$result = $this->Time->fromString('');
$this->assertFalse($result);
$result = $this->Time->fromString(0, 0);
$this->assertFalse($result);
$result = $this->Time->fromString('+1 hour');
$expected = strtotime('+1 hour');
$this->assertEqual($result, $expected);
$timezone = date('Z', time());
$result = $this->Time->fromString('+1 hour', $timezone);
$expected = $this->Time->convert(strtotime('+1 hour'), $timezone);
$this->assertEqual($result, $expected);
}
|
test fromString()
@access public
@return void
|
testFromString
|
php
|
Datawalke/Coordino
|
cake/tests/cases/libs/view/helpers/time.test.php
|
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/time.test.php
|
MIT
|
function testConvertSpecifiers() {
App::build(array(
'locales' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'locale' . DS)
), true);
Configure::write('Config.language', 'time_test');
$time = strtotime('Thu Jan 14 11:43:39 2010');
$result = $this->Time->convertSpecifiers('%a', $time);
$expected = 'jue';
$this->assertEqual($result, $expected);
$result = $this->Time->convertSpecifiers('%A', $time);
$expected = 'jueves';
$this->assertEqual($result, $expected);
$result = $this->Time->convertSpecifiers('%c', $time);
$expected = 'jue %d ene %Y %H:%M:%S %Z';
$this->assertEqual($result, $expected);
$result = $this->Time->convertSpecifiers('%C', $time);
$expected = '20';
$this->assertEqual($result, $expected);
$result = $this->Time->convertSpecifiers('%D', $time);
$expected = '%m/%d/%y';
$this->assertEqual($result, $expected);
$result = $this->Time->convertSpecifiers('%b', $time);
$expected = 'ene';
$this->assertEqual($result, $expected);
$result = $this->Time->convertSpecifiers('%h', $time);
$expected = 'ene';
$this->assertEqual($result, $expected);
$result = $this->Time->convertSpecifiers('%B', $time);
$expected = 'enero';
$this->assertEqual($result, $expected);
$result = $this->Time->convertSpecifiers('%n', $time);
$expected = "\n";
$this->assertEqual($result, $expected);
$result = $this->Time->convertSpecifiers('%n', $time);
$expected = "\n";
$this->assertEqual($result, $expected);
$result = $this->Time->convertSpecifiers('%p', $time);
$expected = 'AM';
$this->assertEqual($result, $expected);
$result = $this->Time->convertSpecifiers('%P', $time);
$expected = 'am';
$this->assertEqual($result, $expected);
$result = $this->Time->convertSpecifiers('%r', $time);
$expected = '%I:%M:%S AM';
$this->assertEqual($result, $expected);
$result = $this->Time->convertSpecifiers('%R', $time);
$expected = '11:43';
$this->assertEqual($result, $expected);
$result = $this->Time->convertSpecifiers('%t', $time);
$expected = "\t";
$this->assertEqual($result, $expected);
$result = $this->Time->convertSpecifiers('%T', $time);
$expected = '%H:%M:%S';
$this->assertEqual($result, $expected);
$result = $this->Time->convertSpecifiers('%u', $time);
$expected = 4;
$this->assertEqual($result, $expected);
$result = $this->Time->convertSpecifiers('%x', $time);
$expected = '%d/%m/%y';
$this->assertEqual($result, $expected);
$result = $this->Time->convertSpecifiers('%X', $time);
$expected = '%H:%M:%S';
$this->assertEqual($result, $expected);
}
|
test converting time specifiers using a time definition localfe file
@access public
@return void
|
testConvertSpecifiers
|
php
|
Datawalke/Coordino
|
cake/tests/cases/libs/view/helpers/time.test.php
|
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/time.test.php
|
MIT
|
function testConvertPercentE() {
if ($this->skipIf(DS !== '\\', 'Cannot run windows tests on non-windows OS')) {
return;
}
$time = strtotime('Thu Jan 14 11:43:39 2010');
$result = $this->Time->convertSpecifiers('%e', $time);
$expected = '14';
$this->assertEqual($result, $expected);
$result = $this->Time->convertSpecifiers('%e', strtotime('2011-01-01'));
$expected = ' 1';
$this->assertEqual($result, $expected);
}
|
test convert %e on windows.
@return void
|
testConvertPercentE
|
php
|
Datawalke/Coordino
|
cake/tests/cases/libs/view/helpers/time.test.php
|
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/time.test.php
|
MIT
|
function testFormatNewSyntax() {
$time = time();
$this->assertEqual($this->Time->format($time), $this->Time->i18nFormat($time));
$this->assertEqual($this->Time->format($time, '%c'), $this->Time->i18nFormat($time, '%c'));
}
|
test new format() syntax which inverts first and secod parameters
@access public
@return void
|
testFormatNewSyntax
|
php
|
Datawalke/Coordino
|
cake/tests/cases/libs/view/helpers/time.test.php
|
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/time.test.php
|
MIT
|
function __construct($content) {
$this->content = $content;
}
|
construct method
@param mixed $content
@access private
@return void
|
__construct
|
php
|
Datawalke/Coordino
|
cake/tests/cases/libs/view/helpers/xml.test.php
|
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/xml.test.php
|
MIT
|
function toString() {
return $this->content;
}
|
toString method
@access public
@return void
|
toString
|
php
|
Datawalke/Coordino
|
cake/tests/cases/libs/view/helpers/xml.test.php
|
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/xml.test.php
|
MIT
|
function testRenderZeroElement() {
$result = $this->Xml->elem('count', null, 0);
$expected = '<count>0</count>';
$this->assertEqual($result, $expected);
$result = $this->Xml->elem('count', null, array('cdata' => true, 'value' => null));
$expected = '<count />';
$this->assertEqual($result, $expected);
}
|
testRenderZeroElement method
@access public
@return void
|
testRenderZeroElement
|
php
|
Datawalke/Coordino
|
cake/tests/cases/libs/view/helpers/xml.test.php
|
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/xml.test.php
|
MIT
|
function testRenderElementWithNamespace() {
$result = $this->Xml->elem('count', array('namespace' => 'myNameSpace'), 'content');
$expected = '<myNameSpace:count>content</myNameSpace:count>';
$this->assertEqual($result, $expected);
$result = $this->Xml->elem('count', array('namespace' => 'myNameSpace'), 'content', false);
$expected = '<myNameSpace:count>content';
$this->assertEqual($result, $expected);
$expected .= '</myNameSpace:count>';
$result .= $this->Xml->closeElem();
$this->assertEqual($result, $expected);
}
|
testRenderElementWithNamespace method
@access public
@return void
|
testRenderElementWithNamespace
|
php
|
Datawalke/Coordino
|
cake/tests/cases/libs/view/helpers/xml.test.php
|
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helpers/xml.test.php
|
MIT
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.