Author: Frederik Holljen Date: 2007-01-28 11:10:46 +0100 (Sun, 28 Jan 2007) New Revision: 4590
Log: - added test case for testing reserved keywords - it is not working or implemented properly yet because there are similar problems in DatabaseSchema. - these issues will have to be resolved first. Added: trunk/PersistentObject/tests/data/keywordtest/ trunk/PersistentObject/tests/data/keywordtest/table.php trunk/PersistentObject/tests/data/keywordtest/table_class.php trunk/PersistentObject/tests/keyword_test.php Modified: trunk/PersistentObject/src/generators/manual_generator.php trunk/PersistentObject/tests/suite.php Modified: trunk/PersistentObject/src/generators/manual_generator.php =================================================================== --- trunk/PersistentObject/src/generators/manual_generator.php 2007-01-27 10:37:31 UTC (rev 4589) +++ trunk/PersistentObject/src/generators/manual_generator.php 2007-01-28 10:10:46 UTC (rev 4590) @@ -36,7 +36,7 @@ // store id $this->id = $state[$def->idProperty->propertyName]; - // check if there is an object with this id already + // check if there is an object with this id already $q = $db->createSelectQuery(); $q->select( '*' )->from( $def->table ) ->where( $q->expr->eq( $def->idProperty->columnName, Added: trunk/PersistentObject/tests/data/keywordtest/table.php =================================================================== --- trunk/PersistentObject/tests/data/keywordtest/table.php 2007-01-27 10:37:31 UTC (rev 4589) +++ trunk/PersistentObject/tests/data/keywordtest/table.php 2007-01-28 10:10:46 UTC (rev 4590) @@ -0,0 +1,31 @@ +<?php +ezcTestRunner::addFileToFilter( __FILE__ ); + +/* + * Holds the definition for PersistentTestObject + * This definition is used by the code manager for + * various tests in the system. + */ +// build definition +$def = new ezcPersistentObjectDefinition(); +$def->table = "table"; +$def->class = "Table"; + +$def->idProperty = new ezcPersistentObjectIdProperty; +$def->idProperty->columnName = 'from'; +$def->idProperty->propertyName = 'from'; +$def->idProperty->visibility = ezcPersistentObjectProperty::VISIBILITY_PRIVATE; +$def->idProperty->generator = new ezcPersistentGeneratorDefinition( 'ezcPersistentSequenceGenerator', + array( 'sequence' => 'PO_test_seq' ) ); + +$def->properties['select'] = new ezcPersistentObjectProperty; +$def->properties['select']->columnName = 'select'; +$def->properties['select']->propertyName = 'select'; +$def->properties['select']->propertyType = ezcPersistentObjectProperty::PHP_TYPE_INT; +$def->properties['select']->defaultValue = 0; +$def->properties['select']->visibility = ezcPersistentObjectProperty::VISIBILITY_PRIVATE; +$def->properties['select']->isRequired = false; + +return $def; + +?> Property changes on: trunk/PersistentObject/tests/data/keywordtest/table.php ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/PersistentObject/tests/data/keywordtest/table_class.php =================================================================== --- trunk/PersistentObject/tests/data/keywordtest/table_class.php 2007-01-27 10:37:31 UTC (rev 4589) +++ trunk/PersistentObject/tests/data/keywordtest/table_class.php 2007-01-28 10:10:46 UTC (rev 4590) @@ -0,0 +1,92 @@ +<?php +ezcTestRunner::addFileToFilter( __FILE__ ); + +/** +CREATE TABLE `table` +( + `from` integer unsigned not null auto_increment, + `select` integer, + PRIMARY KEY (`from`) +) TYPE=InnoDB; +*/ + +class Table +{ + public $from = null; + public $select = null; + + /** + * Inserts some data to use for testing. + */ + public static function insertCleanData() + { + } + + /** + * Saves the schema from database to file. + * + * Use this method if you have changed the definition of the persistent object + * and need to update the file on disk. + */ + public static function saveSchema() + { + $db = ezcDbInstance::get(); + $schema = ezcDbSchema::createFromDb( $db ); +// $schema->writeToFile( 'array', dirname( __FILE__ ) . '/table.dba' ); + } + + /** + * Loads the schema from file into the database. + */ + public static function setupTable() + { + $db = ezcDbInstance::get(); + // Load schema + $schema = ezcDbSchema::createFromFile( 'array', dirname( __FILE__ ) . '/table.dba' ); + $schema->writeToDb( $db ); + + // create sequence if it is a postgres database + if ( $db->getName() == 'pgsql' ) + { + $db->exec( 'CREATE SEQUENCE PO_test_seq START 5' ); + } + + } + + public static function cleanup() + { + $db = ezcDbInstance::get(); + $db->exec( 'DROP TABLE' . $db->quoteIdentifier( 'table' ) ); + if ( $db->getName() == 'pgsql' ) + { + $db->exec( 'DROP SEQUENCE po_test_seq' ); + } + } + + /* + public function saveSqlSchemas() + { + $db = ezcDbInstance::get(); + $schema = ezcDbSchema::createFromFile( 'php', dirname( __FILE__ ) . '/persistent_test_object.dba' ); + $schema->writeToFile( dirname( __FILE__ ) . '/persistent_test_object-pgsql.sql', 'pgsql-file', 'schema' ); + } + */ + + public function setState( array $state ) + { + foreach ( $state as $key => $value ) + { + $this->$key = $value; + } + } + + public function getState() + { + $result = array(); + $result['from'] = $this->from; + $result['select'] = $this->select; + return $result; + } +} + +?> Property changes on: trunk/PersistentObject/tests/data/keywordtest/table_class.php ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/PersistentObject/tests/keyword_test.php =================================================================== --- trunk/PersistentObject/tests/keyword_test.php 2007-01-27 10:37:31 UTC (rev 4589) +++ trunk/PersistentObject/tests/keyword_test.php 2007-01-28 10:10:46 UTC (rev 4590) @@ -0,0 +1,57 @@ +<?php +/** + * @copyright Copyright (C) 2005-2007 eZ systems as. All rights reserved. + * @license http://ez.no/licenses/new_bsd New BSD License + * @version //autogentag// + * @filesource + * @package PersistentObject + * @subpackage Tests + */ +ezcTestRunner::addFileToFilter( __FILE__ ); + +require_once "data/keywordtest/table_class.php"; + +/** + * Tests the code manager. + * + * @package PersistentObject + * @subpackage Tests + */ +class ezcPersistentKeywordTest extends ezcTestCase +{ + private $session = null; + private $hasTables = false; + + protected function setUp() + { + try + { + $db = ezcDbInstance::get(); + } + catch ( Exception $e ) + { + $this->markTestSkipped( 'There was no database configured' ); + } + +// Table::setupTable(); + Table::saveSchema(); +// $this->session = new ezcPersistentSession( ezcDbInstance::get(), +// new ezcPersistentCodeManager( dirname( __FILE__ ) . "/data/keywordtest" ) ); + } + + protected function tearDown() + { +// Table::cleanup(); + } + + public static function suite() + { + return new PHPUnit_Framework_TestSuite( 'ezcPersistentKeywordTest' ); + } + + public function testSave() + { + } +} + +?> Property changes on: trunk/PersistentObject/tests/keyword_test.php ___________________________________________________________________ Name: svn:eol-style + native Modified: trunk/PersistentObject/tests/suite.php =================================================================== --- trunk/PersistentObject/tests/suite.php 2007-01-27 10:37:31 UTC (rev 4589) +++ trunk/PersistentObject/tests/suite.php 2007-01-28 10:10:46 UTC (rev 4590) @@ -23,6 +23,7 @@ require_once( 'many_to_one_relation_test.php' ); require_once( 'one_to_one_relation_test.php' ); require_once( 'many_to_many_relation.php' ); +require_once( 'keyword_test.php' ); /** * @package PersistentObject @@ -46,6 +47,7 @@ $this->addTest( ezcPersistentOneToOneRelationTest::suite() ); $this->addTest( ezcPersistentManyToOneRelationTest::suite() ); $this->addTest( ezcPersistentManyToManyRelationTest::suite() ); +// $this->addTest( ezcPersistentKeywordTest::suite() ); } public static function suite() -- svn-components mailing list svn-components@lists.ez.no http://lists.ez.no/mailman/listinfo/svn-components