Source for file PMO_MyController_Test.php
Documentation is available at PMO_MyController_Test.php
* This file contains the PMO_MyController tests.
* This file is part of the PhpMyObject project,
* an Object-Relational Mapping (ORM) system.
* For questions, help, comments, discussion, etc., please join our
* forum at {@link http://www.developpez.net/forums/forumdisplay.php?f=770}
* or our mailing list at {@link http://groups.google.com/group/pmo-dev}.
* PhpMyObject is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see {@link http://www.gnu.org/licenses/}.
* @author Nicolas Boiteux <nicolas_boiteux@yahoo.fr>
* @author Nicolas Boiteux <nicolas_boiteux@yahoo.fr>
* @link http://pmo.developpez.com/
* @since PhpMyObject v0.15
* @version $Revision: 404 $
* @copyright Copyright (C) 2007-2008 Nicolas Boiteux
* @license GPLv3 {@link http://www.gnu.org/licenses/gpl}
* setup this test case if called individually
require_once(dirname(dirname(__FILE__ )). DIRECTORY_SEPARATOR. 'config.php');
require_once(SIMPLETEST. DS. 'autorun.php');
* requires the PMO_MyController which includes everything needed
require_once(PMO_CORE . DS . 'PMO_Controller.php');
* requires our basic PMO_MyTest template
require_once(dirname(__FILE__ ). DS. 'PMO_MyTest.php');
* tests the PMO_MyController class
$map = $controller->query('SELECT * FROM actor LIMIT 5');
$this->assertTrue(($map instanceof PMO_Map), 'controller returned a PMO_Map');
// then we make sure we have the right number of rows
$this->assertEqual($map->count(), 5);
// and the right data (1, 2, last)
$this->assertEqual($result['actor']->first_name, 'Nicolas');
$this->assertEqual($result['actor']->first_name, 'NICK');
$this->assertEqual($result['actor']->first_name, 'JOHNNY');
// we get 2 errors from PHP when trying to access
// and 2) trying to get a property on a non object
$id = $result['film_actor']->film_id;
$this->fail('Errors were not caught');
$dbms = $controller->rawquery('SELECT * FROM actor LIMIT 5');
$this->assertTrue(($dbms instanceof PMO_Dbms), 'controller returned a PMO_Dbms object');
$row = $dbms->fetchArray();
$this->assertTrue($row['first_name'], 'Nicolas');
$row = $dbms->fetchArray();
$this->assertTrue($row['first_name'], 'NICK');
$row = $dbms->fetchArray();
$row = $dbms->fetchArray();
$row = $dbms->fetchArray();
$this->assertTrue($row['first_name'], 'JOHNNY');
// run the tests if called individually
if (isset ($_GET['level']))
$test = new TestSuite('PMO_MyController Tests');
$test->run(new PMO_HTMLReporter($level));
|