Author: Tobias Schlitt
Date: 2006-09-24 22:37:46 +0200 (Sun, 24 Sep 2006)
New Revision: 3564

Log:
- Added more test cases.

Modified:
   trunk/ConsoleTools/tests/output_format_test.php

Modified: trunk/ConsoleTools/tests/output_format_test.php
===================================================================
--- trunk/ConsoleTools/tests/output_format_test.php     2006-09-24 20:34:13 UTC 
(rev 3563)
+++ trunk/ConsoleTools/tests/output_format_test.php     2006-09-24 20:37:46 UTC 
(rev 3564)
@@ -23,20 +23,144 @@
                return new ezcTestSuite( "ezcConsoleToolsOutputFormatTest" );
        }
 
-    /**
-     * testConstructor
-     * 
-     * @access public
-     */
     public function testConstructor()
     {
-        $fake = new ezcConsoleOutputFormat('default', array( 'default' ), 
'default' );
+        $fake = new ezcConsoleOutputFormat(
+            'default',
+            array( 'default' ),
+            'default',
+            ezcConsoleOutput::TARGET_OUTPUT
+        );
         $this->assertEquals( 
             $fake,
             new ezcConsoleOutputFormat(),
             'Default values incorrect for ezcConsoleOutputFormat.'
         );
     }
+
+    public function testGetAccessSuccess()
+    {
+        $format = new ezcConsoleOutputFormat( 'blue',
+            array( 'bold' ),
+            'red',
+            ezcConsoleOutput::TARGET_STDERR
+        );
+
+        $this->assertEquals( "blue", $format->color );
+        $this->assertEquals( array( "bold" ), $format->style );
+        $this->assertEquals( "red", $format->bgcolor );
+        $this->assertEquals( "php://stderr", $format->target );
+    }
+
+    public function testGetAccessFailure()
+    {
+        $format = new ezcConsoleOutputFormat();
+
+        try
+        {
+            $foo = $format->nonExsitent;
+        }
+        catch ( ezcBasePropertyNotFoundException $e )
+        {
+            return true;
+        }
+        $this->fail( "Exception not thrown on access of not existing property 
on ezcConsoleFormat." );
+    }
+
+    public function testSetAccessSuccess()
+    {
+        $format = new ezcConsoleOutputFormat();
+
+        $format->color = "blue";
+        $format->style = array( "bold" );
+        $format->bgcolor = "red";
+        $format->target = ezcConsoleOutput::TARGET_STDERR;
+
+        $this->assertEquals( "blue", $format->color );
+        $this->assertEquals( array( "bold" ), $format->style );
+        $this->assertEquals( "red", $format->bgcolor );
+        $this->assertEquals( "php://stderr", $format->target );
+        
+        // Style can also be scalar
+        $format->style = "bold";
+        $this->assertEquals( array( "bold" ), $format->style );
+    }
+
+    public function testSetAccessFailureColor()
+    {
+        $format = new ezcConsoleOutputFormat();
+
+        try
+        {
+            $format->color = "nonExistent";
+        }
+        catch ( ezcBaseValueException $e )
+        {
+            return true;
+        }
+        $this->fail( "Exception not thrown on set of not existing color on 
ezcConsoleFormat->color." );
+    }
+
+    public function testSetAccessFailureStyleArray()
+    {
+        $format = new ezcConsoleOutputFormat();
+
+        try
+        {
+            $format->style = array( "nonExistent" );
+        }
+        catch ( ezcBaseValueException $e )
+        {
+            return true;
+        }
+        $this->fail( "Exception not thrown on set of not existing format code 
as array on ezcConsoleFormat->style." );
+    }
+
+    public function testSetAccessFailureStyleScalar()
+    {
+        $format = new ezcConsoleOutputFormat();
+
+        try
+        {
+            $format->style = "nonExistent";
+        }
+        catch ( ezcBaseValueException $e )
+        {
+            return true;
+        }
+        $this->fail( "Exception not thrown on set of not existing format code 
as scalar on ezcConsoleFormat->style." );
+    }
+
+    public function testSetAccessFailureBgcolor()
+    {
+        $format = new ezcConsoleOutputFormat();
+
+        try
+        {
+            $format->bgcolor = "nonExistent";
+        }
+        catch ( ezcBaseValueException $e )
+        {
+            return true;
+        }
+        $this->fail( "Exception not thrown on set of not existing color on 
ezcConsoleFormat->bgcolor." );
+    }
+
+    public function testIssetAccessSuccess()
+    {
+        $format = new ezcConsoleOutputFormat();
+
+        $this->assertTrue( isset( $format->color ) );
+        $this->assertTrue( isset( $format->style ) );
+        $this->assertTrue( isset( $format->bgcolor ) );
+    }
+    
+    public function testIssetAccessFailure()
+    {
+        $format = new ezcConsoleOutputFormat();
+
+        $this->assertFalse( isset( $format->nonExistent ) );
+    }
 }
 
 ?>

-- 
svn-components mailing list
[email protected]
http://lists.ez.no/mailman/listinfo/svn-components

Reply via email to