Author: as
Date: Wed Dec  5 11:51:25 2007
New Revision: 6929

Log:
- Fixed the tests to delete the temporary directories.
- Fixed some whitespaces.
# 2 tests are still failing in template_test.php, it has something to do
  with cache_test.php - need to see what.

Modified:
    trunk/Template/tests/cache_manager_test.php
    trunk/Template/tests/cache_test.php
    trunk/Template/tests/db_cache_manager.php
    trunk/Template/tests/fetch.php
    trunk/Template/tests/locale_test.php
    trunk/Template/tests/template_test.php

Modified: trunk/Template/tests/cache_manager_test.php
==============================================================================
--- trunk/Template/tests/cache_manager_test.php [iso-8859-1] (original)
+++ trunk/Template/tests/cache_manager_test.php [iso-8859-1] Wed Dec  5 
11:51:25 2007
@@ -99,6 +99,7 @@
         // Remove tables.
         $db = ezcDbInstance::get(); 
         $db->exec( 'DROP TABLE user' );
+        $this->removeTempDir();
     }
 
     public function testRenewIncludedTemplates()

Modified: trunk/Template/tests/cache_test.php
==============================================================================
--- trunk/Template/tests/cache_test.php [iso-8859-1] (original)
+++ trunk/Template/tests/cache_test.php [iso-8859-1] Wed Dec  5 11:51:25 2007
@@ -37,6 +37,7 @@
 
     protected function tearDown()
     {
+        $this->removeTempDir();
     }
 
     public function testCacheDirCreation()
@@ -158,7 +159,7 @@
             $out = $t->process( "cache_block_in_dynamic.tpl");
             $this->fail("Expected an exception");
         }
-        catch( ezcTemplateParserException $e )
+        catch ( ezcTemplateParserException $e )
         {
         }
     }
@@ -443,7 +444,7 @@
             $out = $t->process( "cache_template_wrong_order.tpl");
             $this->fail("Expected an exception");
         } 
-        catch( Exception $e)
+        catch ( Exception $e)
         {
         }
     }

Modified: trunk/Template/tests/db_cache_manager.php
==============================================================================
--- trunk/Template/tests/db_cache_manager.php [iso-8859-1] (original)
+++ trunk/Template/tests/db_cache_manager.php [iso-8859-1] Wed Dec  5 11:51:25 
2007
@@ -17,9 +17,9 @@
 
         $r = $q->fetchAll(); // Strange if there is more than one result.
 
-        if( sizeof( $r ) > 0 )
+        if ( sizeof( $r ) > 0 )
         {
-            foreach( $r as $x )
+            foreach ( $r as $x )
             {
                 $id = $r[0]["id"];
 
@@ -68,7 +68,7 @@
 
         $r = $q->fetchAll(); // Expect 0 or 1 result
 
-        if( count($r) == 0 || $r[0]["expired"] == 1 )
+        if ( count($r) == 0 || $r[0]["expired"] == 1 )
         {
             return false;
         }
@@ -79,15 +79,15 @@
         $q->execute();
 
         $rows = $q->fetchAll();
-        foreach( $rows as $r )
+        foreach ( $rows as $r )
         {
-            if( !file_exists( $r["value"] ) )
+            if ( !file_exists( $r["value"] ) )
             {
                 print("The file ". $r["value"] ." doesn't exist\n\n");
             }
             else
             {
-                if( filemtime( $r["value"] ) > filemtime( $cacheName ) )
+                if ( filemtime( $r["value"] ) > filemtime( $cacheName ) )
                 {
                     return false;
                 }
@@ -129,7 +129,7 @@
 
     public function includeTemplate( $template, $template_path )
     {
-        if( $this->depth >= 0 )
+        if ( $this->depth >= 0 )
         {
             $db = ezcDbInstance::get();
             $id = $this->keys[ $this->depth ]["template_id"];
@@ -152,7 +152,7 @@
         $q->execute();
         $rows = $q->fetchAll();
 
-        foreach($rows as $r)
+        foreach ($rows as $r)
         {
             unlink( $r["cache"] );
         }

Modified: trunk/Template/tests/fetch.php
==============================================================================
--- trunk/Template/tests/fetch.php [iso-8859-1] (original)
+++ trunk/Template/tests/fetch.php [iso-8859-1] Wed Dec  5 11:51:25 2007
@@ -12,7 +12,7 @@
         $this->properties["name"] = $name;
         $this->properties["nickname"] = $nickname;
 
-        if( !$this->useSignals ) 
+        if ( !$this->useSignals ) 
         {   
             
ezcTemplateConfiguration::getInstance()->cacheManager->read("user", $id );
         }
@@ -34,13 +34,13 @@
 
     public function __get( $name )
     {
-        switch( $name )
+        switch ( $name )
         {
             case "id":
             case "name":
             case "nickname":
 
-                if( !$this->useSignals ) 
+                if ( !$this->useSignals ) 
                 {   
                     
ezcTemplateConfiguration::getInstance()->cacheManager->read("user", 
$this->properties["id"] );
                 }
@@ -56,7 +56,7 @@
 
     public function __set( $name, $value )
     {
-        switch( $name )
+        switch ( $name )
         {
             case "id":
             case "name":
@@ -102,7 +102,7 @@
         $s = $db->createSelectQuery();
         $s->select( "*")->from("user");
 
-        if( $limit !== null )
+        if ( $limit !== null )
         {
             $s->limit( $limit, $offset );
         }
@@ -116,7 +116,7 @@
         $users = array();
 
         // Execute only when we are creating the template.
-        foreach( $res as $a )
+        foreach ( $res as $a )
         {
             $users[] = new User( $a["id"], $a["name"], $a["nickname"] );
 
@@ -140,7 +140,7 @@
         $res = $statement->fetchAll();
       
         // Execute only when we are creating the template.
-        foreach( $res as $a )
+        foreach ( $res as $a )
         {
             
ezcTemplateConfiguration::getInstance()->cacheManager->read("user", $a["id"] );
         }

Modified: trunk/Template/tests/locale_test.php
==============================================================================
--- trunk/Template/tests/locale_test.php [iso-8859-1] (original)
+++ trunk/Template/tests/locale_test.php [iso-8859-1] Wed Dec  5 11:51:25 2007
@@ -34,6 +34,11 @@
         $config->context = new ezcTemplateNoContext;
     }
 
+    protected function tearDown()
+    {
+        $this->removeTempDir();
+    }
+
     public function testLocale()
     {
         $this->setLocale( LC_ALL, 'de_DE', 'de_DE.UTF-8', 'deu', 'german' );

Modified: trunk/Template/tests/template_test.php
==============================================================================
--- trunk/Template/tests/template_test.php [iso-8859-1] (original)
+++ trunk/Template/tests/template_test.php [iso-8859-1] Wed Dec  5 11:51:25 2007
@@ -54,6 +54,7 @@
     {
         $tc = ezcTemplateConfiguration::getInstance();
         $tc->executeTemplate = true;
+        $this->removeTempDir();
     }
 
     /**
@@ -104,7 +105,7 @@
             $res = $template->process( "sendVar.ezt" ); # Run again, send->a 
is not set.
             $this->fail( "Expected an ezcTemplateRuntimeException");
         }
-        catch( ezcTemplateRuntimeException $e)
+        catch ( ezcTemplateRuntimeException $e)
         {
         }
     }
@@ -203,8 +204,10 @@
             $out = $template->process( "test.ezt", $conf );
             self::fail("Expected a FileNotWriteableException");
         }
-        catch( ezcTemplateFileNotWriteableException $e )
-        {
+        catch ( ezcTemplateFileNotWriteableException $e )
+        {
+            chmod($path, 0700 ); // Changed in order to be deleted
+            chmod(dirname( $path ), 0700 ); // Changed in order to be deleted
         }
 
     }
@@ -228,8 +231,9 @@
             $out = $template->process( "test2.ezt", $conf );
             self::fail("Expected a FileNotWriteableException");
         }
-        catch( ezcTemplateFileNotWriteableException $e )
-        {
+        catch ( ezcTemplateFileNotWriteableException $e )
+        {
+            chmod($dir, 0755 ); // Changed in order to be deleted
         }
     }
 
@@ -254,7 +258,7 @@
         {
             self::assertEquals( "Hello world2",  $template->process( 
"test2.ezt", $conf ) );
             self::fail("Expected an exception");
-        } catch( ezcTemplateException $e)
+        } catch ( ezcTemplateException $e)
         {
             self::assertEquals("The requested template file 
'/this/is/wrong/test2.ezt' does not exist.", $e->getMessage() );
 
@@ -270,7 +274,7 @@
             $out = $template->process("test.ezt");
             self::fail("Expected an exception");
         }
-        catch( ezcTemplateException $e)
+        catch ( ezcTemplateException $e)
         {
             self::assertEquals("The external (use) variable", 
substr($e->getMessage(), 0, 27) );
             self::assertEquals("the application code", 
substr($e->getMessage(), -20) );
@@ -288,7 +292,7 @@
             $out = $template->process("test.ezt");
             self::fail("Expected an exception");
         }
-        catch( ezcTemplateException $e)
+        catch ( ezcTemplateException $e)
         {
             self::assertEquals("The external (use) variable", 
substr($e->getMessage(), 0, 27) );
             self::assertNotEquals("the application code", 
substr($e->getMessage(), -20) );


-- 
svn-components mailing list
svn-components@lists.ez.no
http://lists.ez.no/mailman/listinfo/svn-components

Reply via email to