/usr/share/php/tests/wicked/Wicked/Unit/Driver/SqlTest.php is in php-horde-wicked 2.0.1-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 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 | <?php
/**
* Test the SQL driver.
*
* Copyright 2004-2013 Horde LLC (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (GPLv2). If
* you did not receive this file, see
* http://www.horde.org/licenses/gpl
*
* PHP version 5
*
* @category Horde
* @package Wicked
* @subpackage UnitTests
* @author Jason Felice <jason.m.felice@gmail.com>
* @link http://www.horde.org/apps/wicked
* @license http://www.horde.org/licenses/gpl GNU General Public License, version 2
*/
/**
* Test the restructured text renderer.
*
* @category Horde
* @package Wicked
* @subpackage UnitTests
* @author Gunnar Wrobel <wrobel@pardus.de>
* @link http://www.horde.org/apps/wicked
* @license http://www.horde.org/licenses/gpl GNU General Public License, version 2
*/
class Wicked_Unit_Driver_SqlTest extends Wicked_TestCase
{
/**
* Driver we are testing
* @var object
*/
public $wicked;
public function setUp()
{
$this->markTestIncomplete('This is a very old test case that certainly does not work in its current form. But it may still be useful to be rescued.');
@define('WICKED_BASE', __DIR__ . '/../..');
@define('TEST_PAGE_1', 'driver-pages.phpt Test Page One');
@define('TEST_PAGE_2', 'Renamed driver-pages.phpt Test Page (Called "Two")');
$this->wicked = Wicked_Driver::factory('sql', $this->getTestDatabaseSQLDriverConfig());
}
public function test_Driver_newPage_should_successfully_create_a_page()
{
$this->wicked->removeAllVersions(TEST_PAGE_1);
$this->assertFalse($this->wicked->pageExists(TEST_PAGE_1));
$this->wicked->newPage(TEST_PAGE_1, 'This is a test.');
$this->assertTrue($this->wicked->pageExists(TEST_PAGE_1));
$page = $this->wicked->retrieveByName(TEST_PAGE_1);
$this->assertEqual('This is a test.', $page['page_text']);
}
public function test_updateText_should_also_update_history()
{
$this->wicked->updateText(TEST_PAGE_1, 'Here\'s the new page text.',
'Test change.');
$page = $this->wicked->retrieveByName(TEST_PAGE_1);
$this->assertEqual('Here\'s the new page text.', $page['page_text']);
$last_version = $page['page_version'];
$this->wicked->updateText(TEST_PAGE_1, 'Here\'s the second change.',
'Test change 2.');
$page = $this->wicked->retrieveByName(TEST_PAGE_1);
$this->assertEqual('Here\'s the second change.', $page['page_text']);
$res = $this->wicked->retrieveHistory(TEST_PAGE_1, $last_version);
$this->assertNotEqual(0, count($res),
"no results from retrieveHistory()");
$page = $res[0];
$this->assertEqual('Here\'s the new page text.', $page['page_text']);
}
public function testGetHistoryAndRemoveVersion()
{
$history = $this->wicked->getHistory(TEST_PAGE_1);
$this->assertFalse(count($history) < 2, "need more history to test");
$nvers = count($history);
$item_1 = $history[0];
$item_1_ver = $item_1['page_version'];
$this->wicked->removeVersion(TEST_PAGE_1, $item_1_ver);
$history = $this->wicked->getHistory(TEST_PAGE_1);
$this->assertEqual(count($history), ($nvers - 1));
foreach ($history as $page) {
$testver = $page['page_version'];
$this->assertNotEqual($testver, $item_1_ver,
"removeVersion() version still there.");
}
}
public function testLock()
{
$page = $this->wicked->retrieveByName(TEST_PAGE_1);
$this->assertFalse($page['locked']);
$this->wicked->lock(TEST_PAGE_1, true);
$page = $this->wicked->retrieveByName(TEST_PAGE_1);
$this->assertTrue($page['locked']);
$this->wicked->lock(TEST_PAGE_1, false);
$page = $this->wicked->retrieveByName(TEST_PAGE_1);
$this->assertFalse($page['locked']);
}
public function test_logPageView_should_increment_hit_counter()
{
$page = $this->wicked->retrieveByName(TEST_PAGE_1);
$hits = $page['page_hits'];
$this->wicked->logPageView(TEST_PAGE_1);
$page = $this->wicked->retrieveByName(TEST_PAGE_1);
$this->assertEqual($page['page_hits'], $hits + 1);
}
public function testRenamePage()
{
$this->wicked->renamePage(TEST_PAGE_1, TEST_PAGE_2);
$this->assertFalse($this->wicked->pageExists(TEST_PAGE_1));
$this->assertTrue($this->wicked->pageExists(TEST_PAGE_2));
$this->wicked->renamePage(TEST_PAGE_2, TEST_PAGE_1);
$this->assertTrue($this->wicked->pageExists(TEST_PAGE_1));
$this->assertFalse($this->wicked->pageExists(TEST_PAGE_2));
}
public function testGetPagesAndGetAllPages()
{
$pages = $this->wicked->getPages(false);
$allPages = $this->wicked->getAllPages();
$this->assertEqual(count($allPages), count($pages));
$allPageNames = array();
foreach ($allPages as $allPage) {
$allPageNames[] = $allPage['page_name'];
}
$this->assertFalse(count(array_diff($pages, $allPageNames)) > 0);
$this->assertFalse(count(array_diff($allPageNames, $pages)) > 0);
}
public function test_mostPopular_call_should_not_fail()
{
$this->wicked->mostPopular();
}
public function test_leastPopular_call_should_not_fail()
{
$this->wicked->leastPopular();
}
public function test_recentChanges_call_should_not_fail()
{
$this->wicked->getRecentChanges();
}
public function testSearches()
{
$res = $this->wicked->searchTitles('.phpt');
$this->assertFalse(count($res) < 1, "didn't find all the pages.");
$res = $this->wicked->searchText('second change');
$this->assertFalse(count($res) < 1, "didn't find all the pages.");
$this->wicked->getLikePages('Wiki');
}
public function test_removeAllVersions_should_not_leave_any_versions()
{
$this->wicked->removeAllVersions(TEST_PAGE_1);
$this->assertFalse($this->wicked->pageExists("TEXT_PAGE_1"));
}
}
|