Source for file PMO_MyObject_Test.php
Documentation is available at PMO_MyObject_Test.php
* This file contains the PMO_MyObject 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_MyObject class
* This will test everything PMO_MyObject is supposed to do
/** constructor calls parent contructor. */
$this->assertTrue(is_object($inventory),'$object is an object');
$this->assertTrue(($inventory instanceof PMO_MyObject), '$inventory is an instance of PMO_MyObject');
$inventory->inventory_id = 99;
$this->assertEqual($inventory->film_id, 20);
$this->assertEqual($inventory->store_id, 1);
$inventory->inventory_id = 99;
$film->film_id = $inventory->film_id;
$this->assertEqual($film->title, 'AMELIE HELLFIGHTERS');
$store->store_id = $inventory->store_id;
$this->assertEqual($store->manager_staff_id, 1);
$this->assertEqual($film->film_id, 20);
$this->assertEqual($film->title, 'AMELIE HELLFIGHTERS');
$this->AssertEqual($film->description,
'A Boring Drama of a Woman And a Squirrel who must Conquer a Student in A Baloon');
$this->assertEqual($film->release_year, 2006);
$this->assertEqual($film->language_id, 1);
$this->assertEqual($film->original_language_id, '');
$this->pass('$film->original_language_id is empty');
$this->fail('A NULL value is a perfecty legal value. It should not throw this exception since the attribute exits: '. $e->getMessage());
$this->assertEqual($film->rental_duration, 4);
$this->assertEqual($film->rental_rate, 4.99);
$this->assertEqual($film->length, 79);
$this->assertEqual($film->replacement_cost, 23.99);
$this->assertEqual($film->rating, 'R');
$this->assertEqual($film->special_features, 'Commentaries,Deleted Scenes,Behind the Scenes');
$this->assertEqual($film->last_update, '2006-02-15 05:03:42');
$this->assertEqual($actor->first_name, 'Nicolas');
$this->assertEqual($actor->last_name, 'nico');
$actor->last_name = 'Boiteux';
$this->assertEqual($actor2->last_name, 'Boiteux');
$actor->first_name = 'Louis';
$actor->last_name = 'Lapointe';
$now = date('Y-m-d H:i:s');
$actor->last_update = $now;
$actor2->actor_id = $actor->actor_id;
$this->assertEqual($actor2->actor_id, 21);
$this->assertEqual($actor2->first_name, 'Louis');
$this->assertEqual($actor2->last_name, 'Lapointe');
$actor->first_name = 'Louis';
$actor->last_name = 'Lapointe';
$now = date('Y-m-d H:i:s');
$actor->last_update = $now;
$actor_id = $actor->actor_id;
$actor->actor_id = $actor_id;
$this->assertEqual($actor->last_name, 'Lapointe', 'Just making sur we have a row');
$actor->actor_id = $actor_id;
$this->pass($e->getMessage());
// TODO : POUSUIVRE (plein d'autres choses à tester, les getter et setter d'attributs,
// les getOnjectXXX , etc.
$table = $actor->getTable();
$this->assertTrue(($table instanceof PMO_Table), '$table is an instance or PMO_Table');
$this->assertTrue(($table instanceof PMO_MyTable), '$table is an instance or PMO_MyTable');
$this->assertFalse(($table instanceof PMO_MyTable_actor), '$table is NOT YET an instance oF PMO_MyTable_actor');
$prefix = $cnf->get('PMO_MyTable.CLASS_FILENAME_PREFIX');
$classpath = $cnf->get('PMO_MyTable.CLASSPATH');
$persist = $classpath. $prefix. $file;
$this->assertFalse(file_exists($persist), "Table ". basename($classpath). "/$prefix$file does not exist");
// run the tests if called individually
if (isset ($_GET['level']))
$test = new TestSuite('PMO_MyObject Tests');
$test->add(new PMO_MyObject_attributes_Test);
//$test->add(new PMO_MyObject_get_objects_Test);
$test->run(new PMO_HTMLReporter($level));
|