code
stringlengths 31
1.39M
| docstring
stringlengths 23
16.8k
| func_name
stringlengths 1
126
| language
stringclasses 1
value | repo
stringlengths 7
63
| path
stringlengths 7
166
| url
stringlengths 50
220
| license
stringclasses 7
values |
---|---|---|---|---|---|---|---|
function setUp() {
$this->Time = new TimeHelper();
} | setUp method
@access public
@return void | setUp | 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 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 setUp() {
$this->Xml =& new XmlHelper();
$this->Xml->beforeRender();
$manager =& XmlManager::getInstance();
$manager->namespaces = array();
} | setUp method
@access public
@return void | setUp | 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 testAddNamespace() {
$this->Xml->addNs('custom', 'http://example.com/dtd.xml');
$manager =& XmlManager::getInstance();
$expected = array('custom' => 'http://example.com/dtd.xml');
$this->assertEqual($manager->namespaces, $expected);
} | testAddNamespace method
@access public
@return void | testAddNamespace | 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 testRemoveNamespace() {
$this->Xml->addNs('custom', 'http://example.com/dtd.xml');
$this->Xml->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->Xml->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/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 |
function testRenderElementWithComplexContent() {
$result = $this->Xml->elem('count', array('namespace' => 'myNameSpace'), array('contrived' => 'content'));
$expected = '<myNameSpace:count><content /></myNameSpace:count>';
$this->assertEqual($result, $expected);
$result = $this->Xml->elem('count', array('namespace' => 'myNameSpace'), array('cdata' => true, 'value' => 'content'));
$expected = '<myNameSpace:count><![CDATA[content]]></myNameSpace:count>';
$this->assertEqual($result, $expected);
} | testRenderElementWithComplexContent method
@access public
@return void | testRenderElementWithComplexContent | 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 testSerialize() {
$data = array(
'test1' => 'test with no quotes',
'test2' => 'test with "double quotes"'
);
$result = $this->Xml->serialize($data);
$expected = '<std_class test1="test with no quotes" test2="test with "double quotes"" />';
$this->assertIdentical($result, $expected);
$data = array(
'test1' => 'test with no quotes',
'test2' => 'test without double quotes'
);
$result = $this->Xml->serialize($data);
$expected = '<std_class test1="test with no quotes" test2="test without double quotes" />';
$this->assertIdentical($result, $expected);
$data = array(
'ServiceDay' => array('ServiceTime' => array('ServiceTimePrice' => array('dollar' => 1, 'cents' => '2')))
);
$result = $this->Xml->serialize($data);
$expected = '<service_day><service_time><service_time_price dollar="1" cents="2" /></service_time></service_day>';
$this->assertIdentical($result, $expected);
$data = array(
'ServiceDay' => array('ServiceTime' => array('ServiceTimePrice' => array('dollar' => 1, 'cents' => '2')))
);
$result = $this->Xml->serialize($data, array('format' => 'tags'));
$expected = '<service_day><service_time><service_time_price><dollar>1</dollar><cents>2</cents></service_time_price></service_time></service_day>';
$this->assertIdentical($result, $expected);
$data = array(
'Pages' => array('id' => 2, 'url' => 'http://www.url.com/rb/153/?id=bbbb&t=access')
);
$result = $this->Xml->serialize($data);
$expected = '<pages id="2" url="http://www.url.com/rb/153/?id=bbbb&t=access" />';
$this->assertIdentical($result, $expected);
$test = array(
'Test' => array('test' => true)
);
$expected = '<test test="1" />';
$result = $this->Xml->serialize($test);
$this->assertidentical($expected, $result);
} | testSerialize method
@access public
@return void | testSerialize | 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 testSerializeOnMultiDimensionalArray() {
$data = array(
'Statuses' => array(
array('Status' => array('id' => 1)),
array('Status' => array('id' => 2))
)
);
$result = $this->Xml->serialize($data, array('format' => 'tags'));
$expected = '<statuses><status><id>1</id></status><status><id>2</id></status></statuses>';
$this->assertIdentical($result, $expected);
} | testSerializeOnMultiDimensionalArray method
@access public
@return void | testSerializeOnMultiDimensionalArray | 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 testHeader() {
$expectedDefaultEncoding = Configure::read('App.encoding');
if (empty($expectedDefaultEncoding)) {
$expectedDefaultEncoding = 'UTF-8';
}
$attrib = array();
$result = $this->Xml->header($attrib);
$expected = '<?xml version="1.0" encoding="'.$expectedDefaultEncoding.'" ?>';
$this->assertIdentical($result, $expected);
$attrib = array(
'encoding' => 'UTF-8',
'version' => '1.1'
);
$result = $this->Xml->header($attrib);
$expected = '<?xml version="1.1" encoding="UTF-8" ?>';
$this->assertIdentical($result, $expected);
$attrib = array(
'encoding' => 'UTF-8',
'version' => '1.2',
'additional' => 'attribute'
);
$result = $this->Xml->header($attrib);
$expected = '<?xml version="1.2" encoding="UTF-8" additional="attribute" ?>';
$this->assertIdentical($result, $expected);
$attrib = 'encoding="UTF-8" someOther="value"';
$result = $this->Xml->header($attrib);
$expected = '<?xml encoding="UTF-8" someOther="value" ?>';
$this->assertIdentical($result, $expected);
} | testHeader method
@access public
@return void | testHeader | 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 testElemThenHeader() {
$this->Xml->elem('test', array(), 'foo', false);
$this->assertPattern('/<\?xml/', $this->Xml->header());
} | test that calling elem() and then header() doesn't break
@return void | testElemThenHeader | 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 AclAndAuthGroupTest() {
TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'model' . DS . 'db_acl');
TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'controller' . DS . 'components' . DS . 'acl');
TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'controller' . DS . 'components' . DS . 'auth');
} | AclAndAuthGroupTest method
@access public
@return void | AclAndAuthGroupTest | php | Datawalke/Coordino | cake/tests/groups/acl.group.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/groups/acl.group.php | MIT |
function BakeGroupTest() {
$path = CORE_TEST_CASES . DS . 'console' . DS . 'libs' . DS . 'tasks' . DS;
TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'console' . DS . 'libs' . DS . 'bake');
TestManager::addTestFile($this, $path . 'controller');
TestManager::addTestFile($this, $path . 'model');
TestManager::addTestFile($this, $path . 'view');
TestManager::addTestFile($this, $path . 'fixture');
TestManager::addTestFile($this, $path . 'test');
TestManager::addTestFile($this, $path . 'db_config');
TestManager::addTestFile($this, $path . 'plugin');
TestManager::addTestFile($this, $path . 'project');
} | BakeGroupTest method
@access public
@return void | BakeGroupTest | php | Datawalke/Coordino | cake/tests/groups/bake.group.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/groups/bake.group.php | MIT |
function BehaviorsGroupTest() {
TestManager::addTestCasesFromDirectory($this, CORE_TEST_CASES . DS . 'libs' . DS . 'model' . DS . 'behaviors');
} | BehaviorsGroupTest method
@access public
@return void | BehaviorsGroupTest | php | Datawalke/Coordino | cake/tests/groups/behaviors.group.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/groups/behaviors.group.php | MIT |
function CacheGroupTest() {
TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'cache');
TestManager::addTestCasesFromDirectory($this, CORE_TEST_CASES . DS . 'libs' . DS . 'cache');
} | CacheGroupTest method
@access public
@return void | CacheGroupTest | php | Datawalke/Coordino | cake/tests/groups/cache.group.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/groups/cache.group.php | MIT |
function ComponentsGroupTest() {
TestManager::addTestCasesFromDirectory($this, CORE_TEST_CASES . DS . 'libs' . DS . 'controller' . DS . 'components');
} | CoreComponentsGroupTest method
@access public
@return void | ComponentsGroupTest | php | Datawalke/Coordino | cake/tests/groups/components.group.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/groups/components.group.php | MIT |
function ConfigureGroupTest() {
TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'configure');
TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'class_registry');
} | ConfigureGroupTest method
@access public
@return void | ConfigureGroupTest | php | Datawalke/Coordino | cake/tests/groups/configure.group.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/groups/configure.group.php | MIT |
function ConsoleGroupTest() {
TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'console' . DS . 'cake');
TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'console' . DS . 'libs' . DS . 'acl');
TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'console' . DS . 'libs' . DS . 'api');
TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'console' . DS . 'libs' . DS . 'bake');
TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'console' . DS . 'libs' . DS . 'schema');
TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'console' . DS . 'libs' . DS . 'shell');
$path = CORE_TEST_CASES . DS . 'console' . DS . 'libs' . DS . 'tasks' . DS;
TestManager::addTestFile($this, $path . 'controller');
TestManager::addTestFile($this, $path . 'db_config');
TestManager::addTestFile($this, $path . 'extract');
TestManager::addTestFile($this, $path . 'fixture');
TestManager::addTestFile($this, $path . 'model');
TestManager::addTestFile($this, $path . 'plugin');
TestManager::addTestFile($this, $path . 'project');
TestManager::addTestFile($this, $path . 'test');
TestManager::addTestFile($this, $path . 'view');
} | ConsoleGroupTest method
@access public
@return void | ConsoleGroupTest | php | Datawalke/Coordino | cake/tests/groups/console.group.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/groups/console.group.php | MIT |
function ControllerGroupTest() {
TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'controller' . DS . 'controller');
TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'controller' . DS . 'scaffold');
TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'controller' . DS . 'pages_controller');
TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'controller' . DS . 'component');
TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'controller' . DS . 'controller_merge_vars');
} | LibControllerGroupTest method
@access public
@return void | ControllerGroupTest | php | Datawalke/Coordino | cake/tests/groups/controller.group.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/groups/controller.group.php | MIT |
function DatabaseGroupTest() {
TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'model' . DS . 'db_acl');
TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'model' . DS . 'cake_schema');
TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'model' . DS . 'connection_manager');
TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'model' . DS . 'datasources' . DS . 'dbo_source');
} | ModelGroupTest method
@access public
@return void | DatabaseGroupTest | php | Datawalke/Coordino | cake/tests/groups/database.group.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/groups/database.group.php | MIT |
function HelpersGroupTest() {
TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'view' . DS . 'helper');
TestManager::addTestCasesFromDirectory($this, CORE_TEST_CASES . DS . 'libs' . DS . 'view' . DS . 'helpers');
} | HelpersGroupTest method
@access public
@return void | HelpersGroupTest | php | Datawalke/Coordino | cake/tests/groups/helpers.group.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/groups/helpers.group.php | MIT |
function i18nGroupTest() {
TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'i18n');
TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'l10n');
TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'multibyte');
} | LibGroupTest method
@access public
@return void | i18nGroupTest | php | Datawalke/Coordino | cake/tests/groups/i18n.group.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/groups/i18n.group.php | MIT |
function AllCoreJavascriptHelpersGroupTest() {
$helperTestPath = CORE_TEST_CASES . DS . 'libs' . DS . 'view' . DS . 'helpers' . DS;
TestManager::addTestFile($this, $helperTestPath . 'js.test.php');
TestManager::addTestFile($this, $helperTestPath . 'jquery_engine.test.php');
TestManager::addTestFile($this, $helperTestPath . 'mootools_engine.test.php');
TestManager::addTestFile($this, $helperTestPath . 'prototype_engine.test.php');
} | AllCoreHelpersGroupTest method
@access public
@return void | AllCoreJavascriptHelpersGroupTest | php | Datawalke/Coordino | cake/tests/groups/javascript.group.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/groups/javascript.group.php | MIT |
function LibGroupTest() {
TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'basics');
// TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'inflector');
TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'cake_session');
TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'debugger');
TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'error');
TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'file');
TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'folder');
TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'cake_log');
TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'log' . DS . 'file_log');
TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'class_registry');
TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'overloadable');
TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'sanitize');
TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'security');
TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'set');
TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'string');
TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'validation');
} | LibGroupTest method
@access public
@return void | LibGroupTest | php | Datawalke/Coordino | cake/tests/groups/lib.group.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/groups/lib.group.php | MIT |
function ModelGroupTest() {
TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'model' . DS . 'model_behavior');
TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'model' . DS . 'model_read');
TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'model' . DS . 'model_write');
TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'model' . DS . 'model_delete');
TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'model' . DS . 'model_integration');
TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'model' . DS . 'model_validation');
} | ModelGroupTest method
@access public
@return void | ModelGroupTest | php | Datawalke/Coordino | cake/tests/groups/model.group.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/groups/model.group.php | MIT |
function NoCrossContaminationGroupTest() {
App::import('Core', 'Folder');
$Folder = new Folder(CORE_TEST_CASES);
foreach ($Folder->findRecursive('.*\.test\.php', true) as $file) {
if (in_array(basename($file), $this->blacklist)) {
continue;
}
TestManager::addTestFile($this, $file);
}
} | NoCrossContaminationGroupTest method
@access public
@return void | NoCrossContaminationGroupTest | php | Datawalke/Coordino | cake/tests/groups/no_cross_contamination.group.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/groups/no_cross_contamination.group.php | MIT |
function RoutingSystemGroupTest() {
TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'dispatcher');
TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'router');
} | RoutingSystemGroupTest method
@access public
@return void | RoutingSystemGroupTest | php | Datawalke/Coordino | cake/tests/groups/routing_system.group.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/groups/routing_system.group.php | MIT |
function SocketGroupTest() {
TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'cake_socket');
TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'http_socket');
} | SocketGroupTest method
@access public
@return void | SocketGroupTest | php | Datawalke/Coordino | cake/tests/groups/socket.group.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/groups/socket.group.php | MIT |
function TestSuiteGroupTest() {
TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'test_manager');
TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'code_coverage_manager');
TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'cake_test_case');
TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'cake_test_fixture');
} | TestSuiteGroupTest method
@access public
@return void | TestSuiteGroupTest | php | Datawalke/Coordino | cake/tests/groups/test_suite.group.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/groups/test_suite.group.php | MIT |
function ViewsGroupTest() {
TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'view' . DS . 'view');
TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'view' . DS . 'theme');
} | ViewsGroupTest method
@access public
@return void | ViewsGroupTest | php | Datawalke/Coordino | cake/tests/groups/view.group.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/groups/view.group.php | MIT |
function XmlGroupTest() {
TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'xml');
TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'view' . DS . 'helpers' . DS .'rss');
TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'view' . DS . 'helpers' . DS .'xml');
} | XmlGroupTest method
@access public
@return void | XmlGroupTest | php | Datawalke/Coordino | cake/tests/groups/xml.group.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/groups/xml.group.php | MIT |
function testCase(&$testCase) {
$this->testCase =& $testCase;
} | testCase method
@param CakeTestCase $testCase
@return void
@access public | testCase | php | Datawalke/Coordino | cake/tests/lib/cake_test_case.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/cake_test_case.php | MIT |
function _invoke(&$controller, $params, $missingAction = false) {
$this->controller =& $controller;
if (array_key_exists('layout', $params)) {
$this->controller->layout = $params['layout'];
}
if (isset($this->testCase) && method_exists($this->testCase, 'startController')) {
$this->testCase->startController($this->controller, $params);
}
$result = parent::_invoke($this->controller, $params, $missingAction);
if (isset($this->testCase) && method_exists($this->testCase, 'endController')) {
$this->testCase->endController($this->controller, $params);
}
return $result;
} | invoke method
@param Controller $controller
@param array $params
@param boolean $missingAction
@return Controller
@access protected | _invoke | php | Datawalke/Coordino | cake/tests/lib/cake_test_case.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/cake_test_case.php | MIT |
function assert(&$expectation, $compare, $message = '%s') {
if ($this->_should_skip) {
return;
}
return parent::assert($expectation, $compare, $message);
} | Overrides SimpleTestCase::assert to enable calling of skipIf() from within tests
@param Expectation $expectation
@param mixed $compare
@param string $message
@return boolean|null
@access public | assert | php | Datawalke/Coordino | cake/tests/lib/cake_test_case.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/cake_test_case.php | MIT |
function skipIf($shouldSkip, $message = '%s') {
parent::skipIf($shouldSkip, $message);
return $shouldSkip;
} | Overrides SimpleTestCase::skipIf to provide a boolean return value
@param boolean $shouldSkip
@param string $message
@return boolean
@access public | skipIf | php | Datawalke/Coordino | cake/tests/lib/cake_test_case.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/cake_test_case.php | MIT |
function startController(&$controller, $params = array()) {
if (isset($params['fixturize']) && ((is_array($params['fixturize']) && !empty($params['fixturize'])) || $params['fixturize'] === true)) {
if (!isset($this->db)) {
$this->_initDb();
}
if ($controller->uses === false) {
$list = array($controller->modelClass);
} else {
$list = is_array($controller->uses) ? $controller->uses : array($controller->uses);
}
$models = array();
ClassRegistry::config(array('ds' => $params['connection']));
foreach ($list as $name) {
if ((is_array($params['fixturize']) && in_array($name, $params['fixturize'])) || $params['fixturize'] === true) {
if (class_exists($name) || App::import('Model', $name)) {
$object =& ClassRegistry::init($name);
//switch back to specified datasource.
$object->setDataSource($params['connection']);
$db =& ConnectionManager::getDataSource($object->useDbConfig);
$db->cacheSources = false;
$models[$object->alias] = array(
'table' => $object->table,
'model' => $object->alias,
'key' => strtolower($name),
);
}
}
}
ClassRegistry::config(array('ds' => 'test_suite'));
if (!empty($models) && isset($this->db)) {
$this->_actionFixtures = array();
foreach ($models as $model) {
$fixture =& new CakeTestFixture($this->db);
$fixture->name = $model['model'] . 'Test';
$fixture->table = $model['table'];
$fixture->import = array('model' => $model['model'], 'records' => true);
$fixture->init();
$fixture->create($this->db);
$fixture->insert($this->db);
$this->_actionFixtures[] =& $fixture;
}
foreach ($models as $model) {
$object =& ClassRegistry::getObject($model['key']);
if ($object !== false) {
$object->setDataSource('test_suite');
$object->cacheSources = false;
}
}
}
}
} | Callback issued when a controller's action is about to be invoked through testAction().
@param Controller $controller Controller that's about to be invoked.
@param array $params Additional parameters as sent by testAction().
@return void
@access public | startController | php | Datawalke/Coordino | cake/tests/lib/cake_test_case.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/cake_test_case.php | MIT |
function endController(&$controller, $params = array()) {
if (isset($this->db) && isset($this->_actionFixtures) && !empty($this->_actionFixtures) && $this->dropTables) {
foreach ($this->_actionFixtures as $fixture) {
$fixture->drop($this->db);
}
}
} | Callback issued when a controller's action has been invoked through testAction().
@param Controller $controller Controller that has been invoked.
@param array $params Additional parameters as sent by testAction().
@return void
@access public | endController | php | Datawalke/Coordino | cake/tests/lib/cake_test_case.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/cake_test_case.php | MIT |
function testAction($url, $params = array()) {
$default = array(
'return' => 'result',
'fixturize' => false,
'data' => array(),
'method' => 'post',
'connection' => 'default'
);
if (is_string($params)) {
$params = array('return' => $params);
}
$params = array_merge($default, $params);
$toSave = array(
'case' => null,
'group' => null,
'app' => null,
'output' => null,
'show' => null,
'plugin' => null
);
$this->__savedGetData = (empty($this->__savedGetData))
? array_intersect_key($_GET, $toSave)
: $this->__savedGetData;
$data = (!empty($params['data'])) ? $params['data'] : array();
if (strtolower($params['method']) == 'get') {
$_GET = array_merge($this->__savedGetData, $data);
$_POST = array();
} else {
$_POST = array('data' => $data);
$_GET = $this->__savedGetData;
}
$return = $params['return'];
$params = array_diff_key($params, array('data' => null, 'method' => null, 'return' => null));
$dispatcher =& new CakeTestDispatcher();
$dispatcher->testCase($this);
if ($return != 'result') {
if ($return != 'contents') {
$params['layout'] = false;
}
ob_start();
@$dispatcher->dispatch($url, $params);
$result = ob_get_clean();
if ($return == 'vars') {
$view =& ClassRegistry::getObject('view');
$viewVars = $view->getVars();
$result = array();
foreach ($viewVars as $var) {
$result[$var] = $view->getVar($var);
}
if (!empty($view->pageTitle)) {
$result = array_merge($result, array('title' => $view->pageTitle));
}
}
} else {
$params['return'] = 1;
$params['bare'] = 1;
$params['requested'] = 1;
$result = @$dispatcher->dispatch($url, $params);
}
if (isset($this->_actionFixtures)) {
unset($this->_actionFixtures);
}
ClassRegistry::flush();
return $result;
} | Executes a Cake URL, and can get (depending on the $params['return'] value):
Params:
- 'return' has several possible values:
1. 'result': Whatever the action returns (and also specifies $this->params['requested'] for controller)
2. 'view': The rendered view, without the layout
3. 'contents': The rendered view, within the layout.
4. 'vars': the view vars
- 'fixturize' - Set to true if you want to copy model data from 'connection' to the test_suite connection
- 'data' - The data you want to insert into $this->data in the controller.
- 'connection' - Which connection to use in conjunction with fixturize (defaults to 'default')
- 'method' - What type of HTTP method to simulate (defaults to post)
@param string $url Cake URL to execute (e.g: /articles/view/455)
@param mixed $params Parameters (see above), or simply a string of what to return
@return mixed Whatever is returned depending of requested result
@access public | testAction | php | Datawalke/Coordino | cake/tests/lib/cake_test_case.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/cake_test_case.php | MIT |
function before($method) {
parent::before($method);
if (isset($this->fixtures) && (!is_array($this->fixtures) || empty($this->fixtures))) {
unset($this->fixtures);
}
// Set up DB connection
if (isset($this->fixtures) && strtolower($method) == 'start') {
$this->_initDb();
$this->_loadFixtures();
}
// Create records
if (isset($this->_fixtures) && isset($this->db) && !in_array(strtolower($method), array('start', 'end')) && $this->__truncated && $this->autoFixtures == true) {
foreach ($this->_fixtures as $fixture) {
$inserts = $fixture->insert($this->db);
}
}
if (!in_array(strtolower($method), $this->methods)) {
$this->startTest($method);
}
} | Announces the start of a test.
@param string $method Test method just started.
@return void
@access public | before | php | Datawalke/Coordino | cake/tests/lib/cake_test_case.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/cake_test_case.php | MIT |
function start() {
if (isset($this->_fixtures) && isset($this->db)) {
Configure::write('Cache.disable', true);
$cacheSources = $this->db->cacheSources;
$this->db->cacheSources = false;
$sources = $this->db->listSources();
$this->db->cacheSources = $cacheSources;
if (!$this->dropTables) {
return;
}
foreach ($this->_fixtures as $fixture) {
$table = $this->db->config['prefix'] . $fixture->table;
if (in_array($table, $sources)) {
$fixture->drop($this->db);
$fixture->create($this->db);
} elseif (!in_array($table, $sources)) {
$fixture->create($this->db);
}
}
}
} | Runs as first test to create tables.
@return void
@access public | start | php | Datawalke/Coordino | cake/tests/lib/cake_test_case.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/cake_test_case.php | MIT |
function end() {
if (isset($this->_fixtures) && isset($this->db)) {
if ($this->dropTables) {
foreach (array_reverse($this->_fixtures) as $fixture) {
$fixture->drop($this->db);
}
}
$this->db->sources(true);
Configure::write('Cache.disable', false);
}
if (class_exists('ClassRegistry')) {
ClassRegistry::flush();
}
} | Runs as last test to drop tables.
@return void
@access public | end | php | Datawalke/Coordino | cake/tests/lib/cake_test_case.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/cake_test_case.php | MIT |
function after($method) {
$isTestMethod = !in_array(strtolower($method), array('start', 'end'));
if (isset($this->_fixtures) && isset($this->db) && $isTestMethod) {
foreach (array_reverse($this->_fixtures) as $fixture) {
$fixture->truncate($this->db);
}
$this->__truncated = true;
} else {
$this->__truncated = false;
}
if (!in_array(strtolower($method), $this->methods)) {
$this->endTest($method);
}
$this->_should_skip = false;
parent::after($method);
} | Announces the end of a test.
@param string $method Test method just finished.
@return void
@access public | after | php | Datawalke/Coordino | cake/tests/lib/cake_test_case.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/cake_test_case.php | MIT |
function getTests() {
return array_merge(
array('start', 'startCase'),
array_diff(parent::getTests(), array('testAction', 'testaction')),
array('endCase', 'end')
);
} | Gets a list of test names. Normally that will be all internal methods that start with the
name "test". This method should be overridden if you want a different rule.
@return array List of test names.
@access public | getTests | php | Datawalke/Coordino | cake/tests/lib/cake_test_case.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/cake_test_case.php | MIT |
function loadFixtures() {
$args = func_get_args();
foreach ($args as $class) {
if (isset($this->_fixtureClassMap[$class])) {
$fixture = $this->_fixtures[$this->_fixtureClassMap[$class]];
$fixture->truncate($this->db);
$fixture->insert($this->db);
} else {
trigger_error(sprintf(__('Referenced fixture class %s not found', true), $class), E_USER_WARNING);
}
}
} | Chooses which fixtures to load for a given test
@param string $fixture Each parameter is a model name that corresponds to a
fixture, i.e. 'Post', 'Author', etc.
@return void
@access public
@see CakeTestCase::$autoFixtures | loadFixtures | php | Datawalke/Coordino | cake/tests/lib/cake_test_case.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/cake_test_case.php | MIT |
function assertTags($string, $expected, $fullDebug = false) {
$regex = array();
$normalized = array();
foreach ((array) $expected as $key => $val) {
if (!is_numeric($key)) {
$normalized[] = array($key => $val);
} else {
$normalized[] = $val;
}
}
$i = 0;
foreach ($normalized as $tags) {
if (!is_array($tags)) {
$tags = (string)$tags;
}
$i++;
if (is_string($tags) && $tags{0} == '<') {
$tags = array(substr($tags, 1) => array());
} elseif (is_string($tags)) {
$tagsTrimmed = preg_replace('/\s+/m', '', $tags);
if (preg_match('/^\*?\//', $tags, $match) && $tagsTrimmed !== '//') {
$prefix = array(null, null);
if ($match[0] == '*/') {
$prefix = array('Anything, ', '.*?');
}
$regex[] = array(
sprintf('%sClose %s tag', $prefix[0], substr($tags, strlen($match[0]))),
sprintf('%s<[\s]*\/[\s]*%s[\s]*>[\n\r]*', $prefix[1], substr($tags, strlen($match[0]))),
$i,
);
continue;
}
if (!empty($tags) && preg_match('/^preg\:\/(.+)\/$/i', $tags, $matches)) {
$tags = $matches[1];
$type = 'Regex matches';
} else {
$tags = preg_quote($tags, '/');
$type = 'Text equals';
}
$regex[] = array(
sprintf('%s "%s"', $type, $tags),
$tags,
$i,
);
continue;
}
foreach ($tags as $tag => $attributes) {
$regex[] = array(
sprintf('Open %s tag', $tag),
sprintf('[\s]*<%s', preg_quote($tag, '/')),
$i,
);
if ($attributes === true) {
$attributes = array();
}
$attrs = array();
$explanations = array();
$i = 1;
foreach ($attributes as $attr => $val) {
if (is_numeric($attr) && preg_match('/^preg\:\/(.+)\/$/i', $val, $matches)) {
$attrs[] = $matches[1];
$explanations[] = sprintf('Regex "%s" matches', $matches[1]);
continue;
} else {
$quotes = '["\']';
if (is_numeric($attr)) {
$attr = $val;
$val = '.+?';
$explanations[] = sprintf('Attribute "%s" present', $attr);
} elseif (!empty($val) && preg_match('/^preg\:\/(.+)\/$/i', $val, $matches)) {
$quotes = '["\']?';
$val = $matches[1];
$explanations[] = sprintf('Attribute "%s" matches "%s"', $attr, $val);
} else {
$explanations[] = sprintf('Attribute "%s" == "%s"', $attr, $val);
$val = preg_quote($val, '/');
}
$attrs[] = '[\s]+' . preg_quote($attr, '/') . '=' . $quotes . $val . $quotes;
}
$i++;
}
if ($attrs) {
$permutations = $this->__array_permute($attrs);
$permutationTokens = array();
foreach ($permutations as $permutation) {
$permutationTokens[] = implode('', $permutation);
}
$regex[] = array(
sprintf('%s', implode(', ', $explanations)),
$permutationTokens,
$i,
);
}
$regex[] = array(
sprintf('End %s tag', $tag),
'[\s]*\/?[\s]*>[\n\r]*',
$i,
);
}
}
foreach ($regex as $i => $assertation) {
list($description, $expressions, $itemNum) = $assertation;
$matches = false;
foreach ((array)$expressions as $expression) {
if (preg_match(sprintf('/^%s/s', $expression), $string, $match)) {
$matches = true;
$string = substr($string, strlen($match[0]));
break;
}
}
if (!$matches) {
$this->assert(new TrueExpectation(), false, sprintf('Item #%d / regex #%d failed: %s', $itemNum, $i, $description));
if ($fullDebug) {
debug($string, true);
debug($regex, true);
}
return false;
}
}
return $this->assert(new TrueExpectation(), true, '%s');
} | Takes an array $expected and generates a regex from it to match the provided $string.
Samples for $expected:
Checks for an input tag with a name attribute (contains any non-empty value) and an id
attribute that contains 'my-input':
array('input' => array('name', 'id' => 'my-input'))
Checks for two p elements with some text in them:
array(
array('p' => true),
'textA',
'/p',
array('p' => true),
'textB',
'/p'
)
You can also specify a pattern expression as part of the attribute values, or the tag
being defined, if you prepend the value with preg: and enclose it with slashes, like so:
array(
array('input' => array('name', 'id' => 'preg:/FieldName\d+/')),
'preg:/My\s+field/'
)
Important: This function is very forgiving about whitespace and also accepts any
permutation of attribute order. It will also allow whitespaces between specified tags.
@param string $string An HTML/XHTML/XML string
@param array $expected An array, see above
@param string $message SimpleTest failure output string
@return boolean
@access public | assertTags | php | Datawalke/Coordino | cake/tests/lib/cake_test_case.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/cake_test_case.php | MIT |
function _initDb() {
$testDbAvailable = in_array('test', array_keys(ConnectionManager::enumConnectionObjects()));
$_prefix = null;
if ($testDbAvailable) {
// Try for test DB
restore_error_handler();
@$db =& ConnectionManager::getDataSource('test');
set_error_handler('simpleTestErrorHandler');
$testDbAvailable = $db->isConnected();
}
// Try for default DB
if (!$testDbAvailable) {
$db =& ConnectionManager::getDataSource('default');
$_prefix = $db->config['prefix'];
$db->config['prefix'] = 'test_suite_';
}
ConnectionManager::create('test_suite', $db->config);
$db->config['prefix'] = $_prefix;
// Get db connection
$this->db =& ConnectionManager::getDataSource('test_suite');
$this->db->cacheSources = false;
ClassRegistry::config(array('ds' => 'test_suite'));
} | Initialize DB connection.
@return void
@access protected | _initDb | php | Datawalke/Coordino | cake/tests/lib/cake_test_case.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/cake_test_case.php | MIT |
function _loadFixtures() {
if (!isset($this->fixtures) || empty($this->fixtures)) {
return;
}
if (!is_array($this->fixtures)) {
$this->fixtures = array_map('trim', explode(',', $this->fixtures));
}
$this->_fixtures = array();
foreach ($this->fixtures as $index => $fixture) {
$fixtureFile = null;
if (strpos($fixture, 'core.') === 0) {
$fixture = substr($fixture, strlen('core.'));
foreach (App::core('cake') as $key => $path) {
$fixturePaths[] = $path . 'tests' . DS . 'fixtures';
}
} elseif (strpos($fixture, 'app.') === 0) {
$fixture = substr($fixture, strlen('app.'));
$fixturePaths = array(
TESTS . 'fixtures',
VENDORS . 'tests' . DS . 'fixtures'
);
} elseif (strpos($fixture, 'plugin.') === 0) {
$parts = explode('.', $fixture, 3);
$pluginName = $parts[1];
$fixture = $parts[2];
$fixturePaths = array(
App::pluginPath($pluginName) . 'tests' . DS . 'fixtures',
TESTS . 'fixtures',
VENDORS . 'tests' . DS . 'fixtures'
);
} else {
$fixturePaths = array(
TESTS . 'fixtures',
VENDORS . 'tests' . DS . 'fixtures',
TEST_CAKE_CORE_INCLUDE_PATH . DS . 'cake' . DS . 'tests' . DS . 'fixtures'
);
}
foreach ($fixturePaths as $path) {
if (is_readable($path . DS . $fixture . '_fixture.php')) {
$fixtureFile = $path . DS . $fixture . '_fixture.php';
break;
}
}
if (isset($fixtureFile)) {
require_once($fixtureFile);
$fixtureClass = Inflector::camelize($fixture) . 'Fixture';
$this->_fixtures[$this->fixtures[$index]] =& new $fixtureClass($this->db);
$this->_fixtureClassMap[Inflector::camelize($fixture)] = $this->fixtures[$index];
}
}
if (empty($this->_fixtures)) {
unset($this->_fixtures);
}
} | Load fixtures specified in var $fixtures.
@return void
@access protected | _loadFixtures | php | Datawalke/Coordino | cake/tests/lib/cake_test_case.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/cake_test_case.php | MIT |
function __array_permute($items, $perms = array()) {
static $permuted;
if (empty($perms)) {
$permuted = array();
}
if (empty($items)) {
$permuted[] = $perms;
} else {
$numItems = count($items) - 1;
for ($i = $numItems; $i >= 0; --$i) {
$newItems = $items;
$newPerms = $perms;
list($tmp) = array_splice($newItems, $i, 1);
array_unshift($newPerms, $tmp);
$this->__array_permute($newItems, $newPerms);
}
return $permuted;
}
} | Generates all permutation of an array $items and returns them in a new array.
@param array $items An array of items
@return array
@access private | __array_permute | php | Datawalke/Coordino | cake/tests/lib/cake_test_case.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/cake_test_case.php | MIT |
function init() {
if (isset($this->import) && (is_string($this->import) || is_array($this->import))) {
$import = array_merge(
array('connection' => 'default', 'records' => false),
is_array($this->import) ? $this->import : array('model' => $this->import)
);
if (isset($import['model']) && App::import('Model', $import['model'])) {
ClassRegistry::config(array('ds' => $import['connection']));
$model =& ClassRegistry::init($import['model']);
$db =& ConnectionManager::getDataSource($model->useDbConfig);
$db->cacheSources = false;
$this->fields = $model->schema(true);
$this->fields[$model->primaryKey]['key'] = 'primary';
$this->table = $db->fullTableName($model, false);
ClassRegistry::config(array('ds' => 'test_suite'));
ClassRegistry::flush();
} elseif (isset($import['table'])) {
$model =& new Model(null, $import['table'], $import['connection']);
$db =& ConnectionManager::getDataSource($import['connection']);
$db->cacheSources = false;
$model->useDbConfig = $import['connection'];
$model->name = Inflector::camelize(Inflector::singularize($import['table']));
$model->table = $import['table'];
$model->tablePrefix = $db->config['prefix'];
$this->fields = $model->schema(true);
ClassRegistry::flush();
}
if (!empty($db->config['prefix']) && strpos($this->table, $db->config['prefix']) === 0) {
$this->table = str_replace($db->config['prefix'], '', $this->table);
}
if (isset($import['records']) && $import['records'] !== false && isset($model) && isset($db)) {
$this->records = array();
$query = array(
'fields' => $db->fields($model, null, array_keys($this->fields)),
'table' => $db->fullTableName($model),
'alias' => $model->alias,
'conditions' => array(),
'order' => null,
'limit' => null,
'group' => null
);
$records = $db->fetchAll($db->buildStatement($query, $model), false, $model->alias);
if ($records !== false && !empty($records)) {
$this->records = Set::extract($records, '{n}.' . $model->alias);
}
}
}
if (!isset($this->table)) {
$this->table = Inflector::underscore(Inflector::pluralize($this->name));
}
if (!isset($this->primaryKey) && isset($this->fields['id'])) {
$this->primaryKey = 'id';
}
} | Initialize the fixture.
@param object Cake's DBO driver (e.g: DboMysql).
@access public | init | php | Datawalke/Coordino | cake/tests/lib/cake_test_fixture.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/cake_test_fixture.php | MIT |
function create(&$db) {
if (!isset($this->fields) || empty($this->fields)) {
return false;
}
$this->Schema->_build(array($this->table => $this->fields));
return (
$db->execute($db->createSchema($this->Schema), array('log' => false)) !== false
);
} | Run before all tests execute, should return SQL statement to create table for this fixture could be executed successfully.
@param object $db An instance of the database object used to create the fixture table
@return boolean True on success, false on failure
@access public | create | php | Datawalke/Coordino | cake/tests/lib/cake_test_fixture.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/cake_test_fixture.php | MIT |
function drop(&$db) {
if (empty($this->fields)) {
return false;
}
$this->Schema->_build(array($this->table => $this->fields));
return (
$db->execute($db->dropSchema($this->Schema), array('log' => false)) !== false
);
} | Run after all tests executed, should return SQL statement to drop table for this fixture.
@param object $db An instance of the database object used to create the fixture table
@return boolean True on success, false on failure
@access public | drop | php | Datawalke/Coordino | cake/tests/lib/cake_test_fixture.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/cake_test_fixture.php | MIT |
function insert(&$db) {
if (!isset($this->_insert)) {
$values = array();
if (isset($this->records) && !empty($this->records)) {
$fields = array();
foreach($this->records as $record) {
$fields = array_merge($fields, array_keys(array_intersect_key($record, $this->fields)));
}
$fields = array_unique($fields);
$default = array_fill_keys($fields, null);
foreach ($this->records as $record) {
$recordValues = array();
foreach(array_merge($default, array_map(array(&$db, 'value'), $record)) as $value) {
$recordValues[] = is_null($value) ? 'NULL' : $value;
}
$values[] = '(' . implode(', ', $recordValues) . ')';
}
return $db->insertMulti($this->table, $fields, $values);
}
return true;
}
} | Run before each tests is executed, should return a set of SQL statements to insert records for the table
of this fixture could be executed successfully.
@param object $db An instance of the database into which the records will be inserted
@return boolean on success or if there are no records to insert, or false on failure
@access public | insert | php | Datawalke/Coordino | cake/tests/lib/cake_test_fixture.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/cake_test_fixture.php | MIT |
function truncate(&$db) {
$fullDebug = $db->fullDebug;
$db->fullDebug = false;
$return = $db->truncate($this->table);
$db->fullDebug = $fullDebug;
return $return;
} | Truncates the current fixture. Can be overwritten by classes extending CakeFixture to trigger other events before / after
truncate.
@param object $db A reference to a db instance
@return boolean
@access public | truncate | php | Datawalke/Coordino | cake/tests/lib/cake_test_fixture.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/cake_test_fixture.php | MIT |
function dispatch() {
$this->_checkSimpleTest();
$this->_parseParams();
if ($this->params['group']) {
$this->_runGroupTest();
} elseif ($this->params['case']) {
$this->_runTestCase();
} elseif (isset($_GET['show']) && $_GET['show'] == 'cases') {
$this->_testCaseList();
} else {
$this->_groupTestList();
}
$output = ob_get_clean();
echo $output;
} | Runs the actions required by the URL parameters.
@return void | dispatch | php | Datawalke/Coordino | cake/tests/lib/cake_test_suite_dispatcher.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/cake_test_suite_dispatcher.php | MIT |
function _checkSimpleTest() {
if (!App::import('Vendor', 'simpletest' . DS . 'reporter')) {
$baseDir = $this->_baseDir;
include CAKE_TESTS_LIB . 'templates' . DS . 'simpletest.php';
exit();
}
} | Checks that simpleTest is installed. Will exit if it doesn't
@return void | _checkSimpleTest | php | Datawalke/Coordino | cake/tests/lib/cake_test_suite_dispatcher.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/cake_test_suite_dispatcher.php | MIT |
function _checkXdebug() {
if (!extension_loaded('xdebug')) {
$baseDir = $this->_baseDir;
include CAKE_TESTS_LIB . 'templates' . DS . 'xdebug.php';
exit();
}
} | Checks for the xdebug extension required to do code coverage. Displays an error
if xdebug isn't installed.
@return void | _checkXdebug | php | Datawalke/Coordino | cake/tests/lib/cake_test_suite_dispatcher.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/cake_test_suite_dispatcher.php | MIT |
function _testCaseList() {
$Reporter =& $this->getReporter();
$Reporter->paintDocumentStart();
$Reporter->paintTestMenu();
$Reporter->testCaseList();
$Reporter->paintDocumentEnd();
} | Generates a page containing the a list of test cases that could be run.
@return void | _testCaseList | php | Datawalke/Coordino | cake/tests/lib/cake_test_suite_dispatcher.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/cake_test_suite_dispatcher.php | MIT |
function _groupTestList() {
$Reporter =& $this->getReporter();
$Reporter->paintDocumentStart();
$Reporter->paintTestMenu();
$Reporter->groupTestList();
$Reporter->paintDocumentEnd();
} | Generates a page containing a list of group tests that could be run.
@return void | _groupTestList | php | Datawalke/Coordino | cake/tests/lib/cake_test_suite_dispatcher.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/cake_test_suite_dispatcher.php | MIT |
function &getManager() {
if (empty($this->Manager)) {
$this->Manager = new $this->_managerClass();
}
return $this->Manager;
} | Sets the Manager to use for the request.
@return string The manager class name
@static | getManager | php | Datawalke/Coordino | cake/tests/lib/cake_test_suite_dispatcher.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/cake_test_suite_dispatcher.php | MIT |
function &getReporter() {
static $Reporter = NULL;
if (!$Reporter) {
$type = strtolower($this->params['output']);
$coreClass = 'Cake' . ucwords($this->params['output']) . 'Reporter';
$coreFile = CAKE_TESTS_LIB . 'reporter' . DS . 'cake_' . $type . '_reporter.php';
$appClass = $this->params['output'] . 'Reporter';
$appFile = APPLIBS . 'test_suite' . DS . 'reporter' . DS . $type . '_reporter.php';
if (file_exists($appFile) && include_once $appFile) {
$Reporter =& new $appClass(null, $this->params);
} elseif (include_once $coreFile) {
$Reporter =& new $coreClass(null, $this->params);
}
}
return $Reporter;
} | Gets the reporter based on the request parameters
@return void
@static | getReporter | php | Datawalke/Coordino | cake/tests/lib/cake_test_suite_dispatcher.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/cake_test_suite_dispatcher.php | MIT |
function _parseParams() {
if (!isset($_SERVER['SERVER_NAME'])) {
$_SERVER['SERVER_NAME'] = '';
}
foreach ($this->params as $key => $value) {
if (isset($_GET[$key])) {
$this->params[$key] = $_GET[$key];
}
}
if (isset($_GET['code_coverage'])) {
$this->params['codeCoverage'] = true;
require_once CAKE_TESTS_LIB . 'code_coverage_manager.php';
$this->_checkXdebug();
}
$this->params['baseUrl'] = $this->_baseUrl;
$this->params['baseDir'] = $this->_baseDir;
$this->getManager();
} | Parse url params into a 'request'
@return void | _parseParams | php | Datawalke/Coordino | cake/tests/lib/cake_test_suite_dispatcher.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/cake_test_suite_dispatcher.php | MIT |
function _runGroupTest() {
$Reporter =& CakeTestSuiteDispatcher::getReporter();
if ($this->params['codeCoverage']) {
CodeCoverageManager::init($this->params['group'], $Reporter);
}
if ('all' == $this->params['group']) {
$this->Manager->runAllTests($Reporter);
} else {
$this->Manager->runGroupTest(ucfirst($this->params['group']), $Reporter);
}
} | Runs the group test case.
@return void | _runGroupTest | php | Datawalke/Coordino | cake/tests/lib/cake_test_suite_dispatcher.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/cake_test_suite_dispatcher.php | MIT |
function _runTestCase() {
$Reporter =& CakeTestSuiteDispatcher::getReporter();
if ($this->params['codeCoverage']) {
CodeCoverageManager::init($this->params['case'], $Reporter);
}
$this->Manager->runTestCase($this->params['case'], $Reporter);
} | Runs a test case file.
@return void | _runTestCase | php | Datawalke/Coordino | cake/tests/lib/cake_test_suite_dispatcher.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/cake_test_suite_dispatcher.php | MIT |
function &getInstance() {
static $instance = array();
if (!$instance) {
$instance[0] =& new CodeCoverageManager();
}
return $instance[0];
} | Returns a singleton instance
@return object
@access public | getInstance | php | Datawalke/Coordino | cake/tests/lib/code_coverage_manager.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/code_coverage_manager.php | MIT |
function init($testCaseFile, &$reporter) {
$manager =& CodeCoverageManager::getInstance();
$manager->reporter =& $reporter;
$testCaseFile = str_replace(DS . DS, DS, $testCaseFile);
$thisFile = str_replace('.php', '.test.php', basename(__FILE__));
if (strpos($testCaseFile, $thisFile) !== false) {
trigger_error(__('Xdebug supports no parallel coverage analysis - so this is not possible.', true), E_USER_ERROR);
}
$manager->setParams($reporter);
$manager->testCaseFile = $testCaseFile;
} | Initializes a new Coverage Analyzation for a given test case file
@param string $testCaseFile The test case file being covered.
@param object $reporter Instance of the reporter running.
@return void
@static | init | php | Datawalke/Coordino | cake/tests/lib/code_coverage_manager.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/code_coverage_manager.php | MIT |
function start() {
xdebug_start_code_coverage(XDEBUG_CC_UNUSED | XDEBUG_CC_DEAD_CODE);
} | Start/resume Code coverage collection.
@return void
@static | start | php | Datawalke/Coordino | cake/tests/lib/code_coverage_manager.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/code_coverage_manager.php | MIT |
function setParams(&$reporter) {
if ($reporter->params['app']) {
$this->appTest = true;
}
if ($reporter->params['group']) {
$this->groupTest = true;
}
if ($reporter->params['plugin']) {
$this->pluginTest = Inflector::underscore($reporter->params['plugin']);
}
} | Set the parameters from a reporter to the CodeCoverageManager
@return void | setParams | php | Datawalke/Coordino | cake/tests/lib/code_coverage_manager.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/code_coverage_manager.php | MIT |
function report($output = true) {
$manager =& CodeCoverageManager::getInstance();
CodeCoverageManager::stop();
CodeCoverageManager::clear();
list($coverageData, $testObjectFile) = $manager->_getCoverageData();
if (empty($coverageData) && $output) {
echo "The test object file is never loaded.\n";
}
if (!$manager->groupTest) {
$execCodeLines = $manager->__getExecutableLines(file_get_contents($testObjectFile));
$result = '';
switch (get_class($manager->reporter)) {
case 'CakeHtmlReporter':
$result = $manager->reportCaseHtmlDiff(@file($testObjectFile), $coverageData, $execCodeLines, $manager->numDiffContextLines);
break;
case 'CakeCliReporter':
default:
$result = $manager->reportCaseCli(@file($testObjectFile), $coverageData, $execCodeLines, $manager->numDiffContextLines);
break;
}
} else {
$execCodeLines = $manager->__getExecutableLines($testObjectFile);
$result = '';
switch (get_class($manager->reporter)) {
case 'CakeHtmlReporter':
$result = $manager->reportGroupHtml($testObjectFile, $coverageData, $execCodeLines, $manager->numDiffContextLines);
break;
case 'CakeCliReporter':
default:
$result = $manager->reportGroupCli($testObjectFile, $coverageData, $execCodeLines, $manager->numDiffContextLines);
break;
}
}
if ($output) {
echo $result;
}
} | Stops the current code coverage analyzation and dumps a nice report
depending on the reporter that was passed to start()
@return void
@static | report | php | Datawalke/Coordino | cake/tests/lib/code_coverage_manager.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/code_coverage_manager.php | MIT |
function _getCoverageData() {
$coverageData = array();
$dump = xdebug_get_code_coverage();
if ($this->groupTest) {
$testObjectFile = $this->__testObjectFilesFromGroupFile($this->testCaseFile, $this->appTest);
foreach ($testObjectFile as $file) {
if (!file_exists($file)) {
trigger_error(sprintf(__('This test object file is invalid: %s', true), $file));
return ;
}
}
foreach ($testObjectFile as $file) {
if (isset($dump[$file])) {
$coverageData[$file] = $dump[$file];
}
}
} else {
$testObjectFile = $this->__testObjectFileFromCaseFile($this->testCaseFile, $this->appTest);
if (!file_exists($testObjectFile)) {
trigger_error(sprintf(__('This test object file is invalid: %s', true), $testObjectFile));
return ;
}
if (isset($dump[$testObjectFile])) {
$coverageData = $dump[$testObjectFile];
}
}
return array($coverageData, $testObjectFile);
} | Gets the coverage data for the test case or group test that is being run.
@return void | _getCoverageData | php | Datawalke/Coordino | cake/tests/lib/code_coverage_manager.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/code_coverage_manager.php | MIT |
function reportCaseHtmlDiff($testObjectFile, $coverageData, $execCodeLines, $numContextLines) {
$manager = CodeCoverageManager::getInstance();
$total = count($testObjectFile);
$lines = array();
for ($i = 1; $i < $total + 1; $i++) {
$foundByManualFinder = isset($execCodeLines[$i]) && trim($execCodeLines[$i]) != '';
$foundByXdebug = isset($coverageData[$i]);
if (!$foundByManualFinder || !$foundByXdebug || $coverageData[$i] === -2) {
if (isset($lines[$i])) {
$lines[$i] = 'ignored ' . $lines[$i];
} else {
$lines[$i] = 'ignored';
}
continue;
}
if ($coverageData[$i] !== -1) {
if (isset($lines[$i])) {
$lines[$i] = 'covered ' . $lines[$i];
} else {
$lines[$i] = 'covered';
}
continue;
}
$lines[$i] = 'uncovered show';
$foundEndBlockInContextSearch = false;
for ($j = 1; $j <= $numContextLines; $j++) {
$key = $i - $j;
if ($key > 0 && isset($lines[$key])) {
if (strpos($lines[$key], 'end') !== false) {
$foundEndBlockInContextSearch = true;
if ($j < $numContextLines) {
$lines[$key] = str_replace('end', '', $lines[$key-1]);
}
}
if (strpos($lines[$key], 'uncovered') === false) {
if (strpos($lines[$key], 'covered') !== false) {
$lines[$key] .= ' show';
} else {
$lines[$key] = 'ignored show';
}
}
if ($j == $numContextLines) {
$lineBeforeIsEndBlock = strpos($lines[$key-1], 'end') !== false;
$lineBeforeIsShown = strpos($lines[$key-1], 'show') !== false;
$lineBeforeIsUncovered = strpos($lines[$key-1], 'uncovered') !== false;
if (!$foundEndBlockInContextSearch && !$lineBeforeIsUncovered && ($lineBeforeIsEndBlock)) {
$lines[$key-1] = str_replace('end', '', $lines[$key-1]);
}
if (!$lineBeforeIsShown && !$lineBeforeIsUncovered) {
$lines[$key] .= ' start';
}
}
}
$key = $i + $j;
if ($key < $total) {
$lines[$key] = 'show';
if ($j == $numContextLines) {
$lines[$key] .= ' end';
}
}
}
}
// find the last "uncovered" or "show"n line and "end" its block
$lastShownLine = $manager->__array_strpos($lines, 'show', true);
if (isset($lines[$lastShownLine])) {
$lines[$lastShownLine] .= ' end';
}
// give the first start line another class so we can control the top padding of the entire results
$firstShownLine = $manager->__array_strpos($lines, 'show');
if (isset($lines[$firstShownLine])) {
$lines[$firstShownLine] .= ' realstart';
}
// get the output
$lineCount = $coveredCount = 0;
$report = '';
foreach ($testObjectFile as $num => $line) {
// start line count at 1
$num++;
$class = $lines[$num];
if (strpos($class, 'ignored') === false) {
$lineCount++;
if (strpos($class, 'covered') !== false && strpos($class, 'uncovered') === false) {
$coveredCount++;
}
}
if (strpos($class, 'show') !== false) {
$report .= $manager->__paintCodeline($class, $num, $line);
}
}
return $manager->__paintHeader($lineCount, $coveredCount, $report);
} | Diff reporting
@param string $testObjectFile
@param string $coverageData
@param string $execCodeLines
@param string $output
@return void
@static | reportCaseHtmlDiff | php | Datawalke/Coordino | cake/tests/lib/code_coverage_manager.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/code_coverage_manager.php | MIT |
function reportCaseCli($testObjectFile, $coverageData, $execCodeLines) {
$manager = CodeCoverageManager::getInstance();
$lineCount = $coveredCount = 0;
$report = '';
foreach ($testObjectFile as $num => $line) {
$num++;
$foundByManualFinder = isset($execCodeLines[$num]) && trim($execCodeLines[$num]) != '';
$foundByXdebug = isset($coverageData[$num]) && $coverageData[$num] !== -2;
if ($foundByManualFinder && $foundByXdebug) {
$lineCount++;
if ($coverageData[$num] > 0) {
$coveredCount++;
}
}
}
return $manager->__paintHeaderCli($lineCount, $coveredCount, $report);
} | CLI reporting
@param string $testObjectFile
@param string $coverageData
@param string $execCodeLines
@param string $output
@return void
@static | reportCaseCli | php | Datawalke/Coordino | cake/tests/lib/code_coverage_manager.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/code_coverage_manager.php | MIT |
function reportGroupHtml($testObjectFiles, $coverageData, $execCodeLines, $numContextLines) {
$manager = CodeCoverageManager::getInstance();
$report = '';
foreach ($testObjectFiles as $testObjectFile) {
$lineCount = $coveredCount = 0;
$objFilename = $testObjectFile;
$testObjectFile = file($testObjectFile);
foreach ($testObjectFile as $num => $line) {
$num++;
$foundByManualFinder = isset($execCodeLines[$objFilename][$num]) && trim($execCodeLines[$objFilename][$num]) != '';
$foundByXdebug = isset($coverageData[$objFilename][$num]) && $coverageData[$objFilename][$num] !== -2;
if ($foundByManualFinder && $foundByXdebug) {
$class = 'uncovered';
$lineCount++;
if ($coverageData[$objFilename][$num] > 0) {
$class = 'covered';
$coveredCount++;
}
} else {
$class = 'ignored';
}
}
$report .= $manager->__paintGroupResultLine($objFilename, $lineCount, $coveredCount);
}
return $manager->__paintGroupResultHeader($report);
} | Diff reporting
@param string $testObjectFile
@param string $coverageData
@param string $execCodeLines
@param string $output
@return void
@static | reportGroupHtml | php | Datawalke/Coordino | cake/tests/lib/code_coverage_manager.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/code_coverage_manager.php | MIT |
function reportGroupCli($testObjectFiles, $coverageData, $execCodeLines) {
$manager = CodeCoverageManager::getInstance();
$report = '';
foreach ($testObjectFiles as $testObjectFile) {
$lineCount = $coveredCount = 0;
$objFilename = $testObjectFile;
$testObjectFile = file($testObjectFile);
foreach ($testObjectFile as $num => $line) {
$num++;
$foundByManualFinder = isset($execCodeLines[$objFilename][$num]) && trim($execCodeLines[$objFilename][$num]) != '';
$foundByXdebug = isset($coverageData[$objFilename][$num]) && $coverageData[$objFilename][$num] !== -2;
if ($foundByManualFinder && $foundByXdebug) {
$lineCount++;
if ($coverageData[$objFilename][$num] > 0) {
$coveredCount++;
}
}
}
$report .= $manager->__paintGroupResultLineCli($objFilename, $lineCount, $coveredCount);
}
return $report;
} | CLI reporting
@param string $testObjectFile
@param string $coverageData
@param string $execCodeLines
@param string $output
@return void
@static | reportGroupCli | php | Datawalke/Coordino | cake/tests/lib/code_coverage_manager.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/code_coverage_manager.php | MIT |
function __testObjectFileFromCaseFile($file, $isApp = true) {
$manager = CodeCoverageManager::getInstance();
$path = $manager->__getTestFilesPath($isApp);
$folderPrefixMap = array(
'behaviors' => 'models',
'components' => 'controllers',
'helpers' => 'views'
);
foreach ($folderPrefixMap as $dir => $prefix) {
if (strpos($file, $dir) === 0) {
$path .= $prefix . DS;
break;
}
}
$testManager =& new TestManager();
$testFile = str_replace(array('/', $testManager->_testExtension), array(DS, '.php'), $file);
$folder =& new Folder();
$folder->cd(ROOT . DS . CAKE_TESTS_LIB);
$contents = $folder->read();
if (in_array(basename($testFile), $contents[1])) {
$testFile = basename($testFile);
$path = ROOT . DS . CAKE_TESTS_LIB;
}
$path .= $testFile;
$realpath = realpath($path);
if ($realpath) {
return $realpath;
}
return $path;
} | Returns the name of the test object file based on a given test case file name
@param string $file
@param string $isApp
@return string name of the test object file
@access private | __testObjectFileFromCaseFile | php | Datawalke/Coordino | cake/tests/lib/code_coverage_manager.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/code_coverage_manager.php | MIT |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.