Author: ts Date: Mon Nov 26 19:09:46 2007 New Revision: 6816 Log: - #012022: PersistentObjectDatabaseSchemaTiein not passing it's tests. # Some errors were produced by whitespace changes in # ezcDbSchemaPersistentWriter. - Refactored test cases of PersistentObjectDatabaseSchemaTiein to use preg_match() instead of comparing the whole output to avoid any issues produced by different consoles used for testing (like stated in the issue, too).
Modified: trunk/DatabaseSchema/ChangeLog trunk/DatabaseSchema/src/handlers/persistent/writer.php trunk/PersistentObjectDatabaseSchemaTiein/ChangeLog trunk/PersistentObjectDatabaseSchemaTiein/tests/data.php trunk/PersistentObjectDatabaseSchemaTiein/tests/test.php Modified: trunk/DatabaseSchema/ChangeLog ============================================================================== --- trunk/DatabaseSchema/ChangeLog [iso-8859-1] (original) +++ trunk/DatabaseSchema/ChangeLog [iso-8859-1] Mon Nov 26 19:09:46 2007 @@ -1,3 +1,11 @@ +1.3beta1 - [RELEASEDATE] +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +- #012022: PersistentObjectDatabaseSchemaTiein not passing it's tests. + (Whitespace changes in generated PersistentObject definitions made + PersistentObjectDatabaseSchemaTiein fail.) + + 1.3alpha1 - Monday 29 October 2007 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Modified: trunk/DatabaseSchema/src/handlers/persistent/writer.php ============================================================================== --- trunk/DatabaseSchema/src/handlers/persistent/writer.php [iso-8859-1] (original) +++ trunk/DatabaseSchema/src/handlers/persistent/writer.php [iso-8859-1] Mon Nov 26 19:09:46 2007 @@ -109,11 +109,11 @@ fwrite( $file, "\$def->idProperty->propertyName = '$fieldName';\n" ); if ( $field->autoIncrement ) { - fwrite( $file, "\$def->idProperty->generator = new ezcPersistentGeneratorDefinition( 'ezcPersistentSequenceGenerator' );\n" ); + fwrite( $file, "\$def->idProperty->generator = new ezcPersistentGeneratorDefinition( 'ezcPersistentSequenceGenerator' );\n" ); } else { - fwrite( $file, "\$def->idProperty->generator = new ezcPersistentGeneratorDefinition( 'ezcPersistentManualGenerator' );\n" ); + fwrite( $file, "\$def->idProperty->generator = new ezcPersistentGeneratorDefinition( 'ezcPersistentManualGenerator' );\n" ); } } else Modified: trunk/PersistentObjectDatabaseSchemaTiein/ChangeLog ============================================================================== --- trunk/PersistentObjectDatabaseSchemaTiein/ChangeLog [iso-8859-1] (original) +++ trunk/PersistentObjectDatabaseSchemaTiein/ChangeLog [iso-8859-1] Mon Nov 26 19:09:46 2007 @@ -1,3 +1,9 @@ +1.2.1 - [RELEASEDATE] +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +- #012022: PersistentObjectDatabaseSchemaTiein not passing it's tests. + + 1.2 - Monday 02 July 2007 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Modified: trunk/PersistentObjectDatabaseSchemaTiein/tests/data.php ============================================================================== --- trunk/PersistentObjectDatabaseSchemaTiein/tests/data.php [iso-8859-1] (original) +++ trunk/PersistentObjectDatabaseSchemaTiein/tests/data.php [iso-8859-1] Mon Nov 26 19:09:46 2007 @@ -140,11 +140,13 @@ $res['testValidFromFileWithClasses'] = '[34;1meZ components PersistentObject definition generator[0m[m [0m[0m[0m[m [0m[34;1mPersistentObject definition successfully written to +[0m[34;1mClass files successfully written to [0m'; $res['testValidFromFileWithClassesAndPrefix'] = '[34;1meZ components PersistentObject definition generator[0m[m [0m[0m[0m[m [0m[34;1mPersistentObject definition successfully written to +[0m[34;1mClass files successfully written to [0m'; return $res; Modified: trunk/PersistentObjectDatabaseSchemaTiein/tests/test.php ============================================================================== --- trunk/PersistentObjectDatabaseSchemaTiein/tests/test.php [iso-8859-1] (original) +++ trunk/PersistentObjectDatabaseSchemaTiein/tests/test.php [iso-8859-1] Mon Nov 26 19:09:46 2007 @@ -44,49 +44,77 @@ chdir( $oldDir ); // file_put_contents( __FUNCTION__, substr( $res, 0, 203 ) ); - $this->assertEquals( $this->results[__FUNCTION__], substr( $res, 0, 203 ), "Error output incorrect with no parameters." ); + $this->assertEquals( + 1, + preg_match( '(Error\swhile\sprocessing\syour\soptions:\sArgument\swith\sname\s\'def dir\'\sis\smandatory\sbut\swas\snot\ssubmitted\.)s', $res ), + 'Error message not found in generated output.' + ); } public function testNoParameters() { $res = `php PersistentObjectDatabaseSchemaTiein/src/rungenerator.php`; // file_put_contents( __FUNCTION__, $res ); - $this->assertEquals( $this->results[__FUNCTION__], $res, "Error output incorrect with no parameters." ); + $this->assertEquals( + 1, + preg_match( '(Error\swhile\sprocessing\syour\soptions:\sArgument\swith\sname\s\'def dir\'\sis\smandatory\sbut\swas\snot\ssubmitted\.)s', $res ), + 'Error message not found in generated output.' + ); } public function testOnlySourceParameter() { $res = `php PersistentObjectDatabaseSchemaTiein/src/rungenerator.php -s test`; // file_put_contents( __FUNCTION__, $res ); - $this->assertEquals( $this->results[__FUNCTION__], $res, "Error output incorrect with no parameters." ); + $this->assertEquals( + 1, + preg_match( '(Error\swhile\sprocessing\syour\soptions:\sArgument\swith\sname\s\'def dir\'\sis\smandatory\sbut\swas\snot\ssubmitted\.)s', $res ), + 'Error message not found in generated output.' + ); } public function testOnlyFormatParameter() { $res = `php PersistentObjectDatabaseSchemaTiein/src/rungenerator.php -f test`; // file_put_contents( __FUNCTION__, $res ); - $this->assertEquals( $this->results[__FUNCTION__], $res, "Error output incorrect with no parameters." ); + $this->assertEquals( + 1, + preg_match( '(Error\swhile\sprocessing\syour\soptions:\sArgument\swith\sname\s\'def dir\'\sis\smandatory\sbut\swas\snot\ssubmitted\.)s', $res ), + 'Error message not found in generated output.' + ); } public function testFormatSourceParameter() { $res = `php PersistentObjectDatabaseSchemaTiein/src/rungenerator.php -f test -s test`; // file_put_contents( __FUNCTION__, $res ); - $this->assertEquals( $this->results[__FUNCTION__], $res, "Error output incorrect with no parameters." ); + $this->assertEquals( + 1, + preg_match( '(Error\swhile\sprocessing\syour\soptions:\sArgument\swith\sname\s\'def dir\'\sis\smandatory\sbut\swas\snot\ssubmitted\.)s', $res ), + 'Error message not found in generated output.' + ); } public function testInvalidFormat() { $res = `php PersistentObjectDatabaseSchemaTiein/src/rungenerator.php -f test -s test test`; // file_put_contents( __FUNCTION__, $res ); - $this->assertEquals( $this->results[__FUNCTION__], $res, "Error output incorrect with no parameters." ); + $this->assertEquals( + 1, + preg_match( '(Error\sreading\sschema:\sThere\sis no\s\'read\'\shandler\savailable\sfor\sthe\s\'test\'\sformat\.)s', $res ), + 'Error message not found in generated output.' + ); } public function testInvalidSource() { $res = `php PersistentObjectDatabaseSchemaTiein/src/rungenerator.php -f xml -s test test`; // file_put_contents( __FUNCTION__, $res ); - $this->assertEquals( $this->results[__FUNCTION__], $res, "Error output incorrect with no parameters." ); + $this->assertEquals( + 1, + preg_match( '(Error\sreading\sschema:\sThe\sschema\sfile\s\'test\'\scould\snot\sbe\sfound\.)s', $res ), + 'Error message not found in generated output.' + ); } public function testInvalidDestination() @@ -94,7 +122,11 @@ $source = dirname( __FILE__ ) . "/data/webbuilder.schema.xml"; $res = `php PersistentObjectDatabaseSchemaTiein/src/rungenerator.php -f xml -s $source test`; // file_put_contents( __FUNCTION__, $res ); - $this->assertEquals( $this->results[__FUNCTION__], $res, "Error output incorrect with no parameters." ); + $this->assertEquals( + 1, + preg_match( '(Error\swriting\sschema:\sThe\sdirectory\sfile\s\'test\'\scould\snot\sbe\sfound\.)s', $res ), + 'Error message not found in generated output.' + ); } public function testValidFromFile() @@ -103,20 +135,19 @@ $destination = $this->createTempDir( "PersObjDatSchem" ); $res = `php PersistentObjectDatabaseSchemaTiein/src/rungenerator.php -f xml -s $source $destination`; // file_put_contents( __FUNCTION__, $res ); - - // Sanitize because of temp dir name - $res = explode( "\n", $res ); - unset( $res[3], $res[4] ); - $res = implode( "\n", $res ); - - $this->assertEquals( $this->results[__FUNCTION__], $res, "Error output incorrect with no parameters." ); + + $this->assertEquals( + 1, + preg_match( '(PersistentObject\sdefinition\ssuccessfully\swritten\sto)s', $res ), + 'No success message found in generated output.' + ); foreach ( glob( dirname( __FILE__ ) . "/data/definition_only/definitions/*.php" ) as $file ) { $this->assertEquals( file_get_contents( $file ), file_get_contents( $destination . "/" . basename( $file ) ), - "Geneator generated an invalid persistent object definition file." + "Geneator generated an invalid persistent object definition file '$file'." ); } @@ -134,19 +165,18 @@ $res = `php PersistentObjectDatabaseSchemaTiein/src/rungenerator.php -f xml -s $source "$destination/definitions" "$destination/classes"`; // file_put_contents( __FUNCTION__, $res ); - // Sanitize because of temp dir name - $res = explode( "\n", $res ); - unset( $res[3], $res[4] ); - $res = implode( "\n", $res ); - - $this->assertEquals( $this->results[__FUNCTION__], $res, "Error output incorrect with no parameters." ); + $this->assertEquals( + 1, + preg_match( '(PersistentObject\sdefinition\ssuccessfully\swritten\sto)s', $res ), + 'No success message found in generated output.' + ); foreach ( glob( dirname( __FILE__ ) . "/data/definition_class/definitions/*.php" ) as $file ) { $this->assertEquals( file_get_contents( $file ), file_get_contents( $destination . "/definitions/" . basename( $file ) ), - "Geneator generated an invalid persistent object definition file." + "Geneator generated an invalid persistent object definition file, compared to '$file'." ); } @@ -155,7 +185,7 @@ $this->assertEquals( file_get_contents( $file ), file_get_contents( $destination . "/classes/" . basename( $file ) ), - "Geneator generated an invalid persistent object definition file." + "Geneator generated an invalid persistent object class file, compared to '$file'." ); } @@ -173,19 +203,18 @@ $res = `php PersistentObjectDatabaseSchemaTiein/src/rungenerator.php -p ezcapp -f xml -s $source "$destination/definitions" "$destination/classes"`; // file_put_contents( __FUNCTION__, $res ); - // Sanitize because of temp dir name - $res = explode( "\n", $res ); - unset( $res[3], $res[4] ); - $res = implode( "\n", $res ); - - $this->assertEquals( $this->results[__FUNCTION__], $res, "Error output incorrect with no parameters." ); + $this->assertEquals( + 1, + preg_match( '(PersistentObject\sdefinition\ssuccessfully\swritten\sto)s', $res ), + 'No success message found in generated output.' + ); foreach ( glob( dirname( __FILE__ ) . "/data/definition_class_prefix/definitions/*.php" ) as $file ) { $this->assertEquals( file_get_contents( $file ), file_get_contents( $destination . "/definitions/" . basename( $file ) ), - "Geneator generated an invalid persistent object definition file." + "Geneator generated an invalid persistent object definition file, compared to '$file'." ); } @@ -194,7 +223,7 @@ $this->assertEquals( file_get_contents( $file ), file_get_contents( $destination . "/classes/" . basename( $file ) ), - "Geneator generated an invalid persistent object definition file." + "Geneator generated an invalid persistent object class file, compared to '$file'." ); } @@ -209,12 +238,11 @@ $res = `php PersistentObjectDatabaseSchemaTiein/src/rungenerator.php -f xml -s $source $destination`; // file_put_contents( __FUNCTION__, $res ); - // Sanitize because of temp dir name - $res = explode( "\n", $res ); - unset( $res[3], $res[4] ); - $res = implode( "\n", $res ); - - $this->assertEquals( $this->results[__FUNCTION__], $res, "Error output incorrect with no parameters." ); + $this->assertEquals( + 1, + preg_match( '(Error\swriting\sschema:\sAn\serror\soccurred\swhile\swriting\sto)s', $res ), + 'Error message not found in generated output.' + ); $this->removeTempDir(); } @@ -228,12 +256,11 @@ $res = `php PersistentObjectDatabaseSchemaTiein/src/rungenerator.php -f xml -s $source -o $destination`; // file_put_contents( __FUNCTION__, $res ); - // Sanitize because of temp dir name - $res = explode( "\n", $res ); - unset( $res[3], $res[4] ); - $res = implode( "\n", $res ); - - $this->assertEquals( $this->results[__FUNCTION__], $res, "Error output incorrect with no parameters." ); + $this->assertEquals( + 1, + preg_match( '(PersistentObject\sdefinition\ssuccessfully\swritten\sto)s', $res ), + 'No success message found in generated output.' + ); $this->removeTempDir(); } @@ -260,12 +287,11 @@ // real test $res = `php PersistentObjectDatabaseSchemaTiein/src/rungenerator.php -f "$type" -s "$dsn" "$destination"`; - // Sanitize because of temp dir name - $res = explode( "\n", $res ); - unset( $res[3], $res[4] ); - $res = implode( "\n", $res ); - - $this->assertEquals( $this->results[__FUNCTION__], $res, "Error output incorrect with no parameters." ); + $this->assertEquals( + 1, + preg_match( '(PersistentObject\sdefinition\ssuccessfully\swritten\sto)s', $res ), + 'No success message found in generated output.' + ); foreach ( glob( dirname( __FILE__ ) . "/data/definition_only/definitions/*.php" ) as $file ) { @@ -298,7 +324,11 @@ // real test $res = `php PersistentObjectDatabaseSchemaTiein/src/rungenerator.php -f "$type" -s "$dsn" "$destination"`; - $this->assertEquals( $this->results[__FUNCTION__], substr( $res, 0, 115 ), "Error output incorrect with no parameters." ); + $this->assertEquals( + 1, + preg_match( '(Error\sreading\sschema)s', $res ), + 'No success error found in generated output.' + ); $this->removeTempDir(); } -- svn-components mailing list svn-components@lists.ez.no http://lists.ez.no/mailman/listinfo/svn-components