/usr/share/php/tests/turba/Turba/ToDo/ViewListTest.php is in php-horde-turba 4.1.3-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | <?php
require_once __DIR__ . '/TestBase.php';
/**
* @author Jason M. Felice <jason.m.felice@gmail.com>
* @package Turba
* @subpackage UnitTests
*/
class Turba_ToDo_ViewListTest extends Turba_TestBase {
function setUp()
{
$this->markTestIncomplete('Convert to use Horde_Test.');
parent::setUp();
$this->setUpDatabase();
require_once __DIR__ . '/../View/List.php';
}
function callView_List($method, &$numDisplayed, $param = null)
{
$GLOBALS['source'] = '_test_sql';
$GLOBALS['cfgSources'] = array('_test_sql' => $this->getDriverConfig());
$list = $this->getList();
$sources = Turba::getColumns();
$columns = isset($sources['_test_sql']) ? $sources['_test_sql'] : array();
$view = new Turba_View_List($list, null, $columns);
$this->_output = $view->$method($numDisplayed, $param);
$this->assertOk($this->_output);
$this->assertNoUnwantedPattern('/Fatal error/', $this->_output);
$this->assertNoUnwantedPattern('/Warning/', $this->_output);
return $view;
}
function test_getAddSources_returns_sources_sorted_by_name()
{
$result = Turba_View_List::getAddSources();
if (!$this->assertOk($result)) {
return;
}
list($addToList, $addToListSources) = $result;
$groups = $this->_groups;
sort($groups);
foreach ($addToList as $item) {
if (!empty($groups) && !empty($item['name']) &&
$groups[0] == $item['name']) {
array_shift($groups);
}
}
$this->assertTrue(empty($groups),
"Some group not found or not found in right order.");
}
function test_getPage_renders_all_list_items()
{
$this->callView_List('getPage', $numDisplayed);
foreach ($this->_sortedByLastname as $name) {
$this->assertWantedPattern('/' . preg_quote($name, '/') . '/',
$this->_output);
}
$this->assertEqual(count($this->_sortedByLastname), $numDisplayed);
}
function test_getAlpha_renders_filtered_items()
{
$this->callView_List('getAlpha', $numDisplayed, 'j');
$count = 0;
foreach ($this->_sortedByLastname as $name) {
if (Horde_String::lower($name{0}) == 'j') {
$this->assertWantedPattern('/' . preg_quote($name, '/') . '/',
$this->_output);
$count++;
} else {
$this->assertNoUnwantedPattern('/' . preg_quote($name, '/') .
'/', $this->_output);
}
}
$this->assertEqual($count, $numDisplayed);
$this->assertNotEqual(0, $count);
}
}
|