Author: Sebastian Bergmann
Date: 2006-06-15 21:10:42 +0200 (Thu, 15 Jun 2006)
New Revision: 3139

Log:
assert{private|protected}PropertySame() -> assertSame( ..., 
getNonPublicProperty())
Modified:
   trunk/Configuration/tests/configuration_array_writer_test.php
   trunk/Configuration/tests/configuration_ini_writer_test.php
   trunk/Configuration/tests/configuration_manager_test.php
   trunk/Configuration/tests/configuration_test.php
   trunk/Graph/tests/chart_test.php
   trunk/Template/tests/compiled_code_test.php
   trunk/Template/tests/configuration_test.php
   trunk/UnitTest/src/test/case.php

Modified: trunk/Configuration/tests/configuration_array_writer_test.php
===================================================================
--- trunk/Configuration/tests/configuration_array_writer_test.php       
2006-06-15 18:27:22 UTC (rev 3138)
+++ trunk/Configuration/tests/configuration_array_writer_test.php       
2006-06-15 19:10:42 UTC (rev 3139)
@@ -121,7 +121,7 @@
         $backend = new ezcConfigurationArrayWriter( 'files/write_basic.php', 
new ezcConfiguration() );
         $this->assertEquals( 'files', $backend->getLocation() );
         $this->assertEquals( 'write_basic', $backend->getName() );
-        $this->assertProtectedPropertySame( $backend, 'permissions', 0666 );
+        $this->assertSame( 0666, $this->getNonPublicProperty( $backend, 
'permissions' ) );
     }
 
     public function testInitCtor2()
@@ -129,7 +129,7 @@
         $backend = new ezcConfigurationArrayWriter( 
'files.foo/write_basic.php', new ezcConfiguration(), 0660 );
         $this->assertEquals( 'files.foo', $backend->getLocation() );
         $this->assertEquals( 'write_basic', $backend->getName() );
-        $this->assertProtectedPropertySame( $backend, 'permissions', 0660 );
+        $this->assertSame( 0660, $this->getNonPublicProperty( $backend, 
'permissions' ) );
     }
 
     public function testInitCtor3()

Modified: trunk/Configuration/tests/configuration_ini_writer_test.php
===================================================================
--- trunk/Configuration/tests/configuration_ini_writer_test.php 2006-06-15 
18:27:22 UTC (rev 3138)
+++ trunk/Configuration/tests/configuration_ini_writer_test.php 2006-06-15 
19:10:42 UTC (rev 3139)
@@ -121,7 +121,7 @@
         $backend = new ezcConfigurationIniWriter( 'files/write_basic.ini', new 
ezcConfiguration() );
         $this->assertEquals( 'files', $backend->getLocation() );
         $this->assertEquals( 'write_basic', $backend->getName() );
-        $this->assertProtectedPropertySame( $backend, 'permissions', 0666 );
+        $this->assertSame( 0666, $this->getNonPublicProperty( $backend, 
'permissions' ) );
     }
 
     public function testInitCtor2()
@@ -129,7 +129,7 @@
         $backend = new ezcConfigurationIniWriter( 'files.foo/write_basic.ini', 
new ezcConfiguration(), 0660 );
         $this->assertEquals( 'files.foo', $backend->getLocation() );
         $this->assertEquals( 'write_basic', $backend->getName() );
-        $this->assertProtectedPropertySame( $backend, 'permissions', 0660 );
+        $this->assertSame( 0660, $this->getNonPublicProperty( $backend, 
'permissions' ) );
     }
 
     public function testInitCtor3()

Modified: trunk/Configuration/tests/configuration_manager_test.php
===================================================================
--- trunk/Configuration/tests/configuration_manager_test.php    2006-06-15 
18:27:22 UTC (rev 3138)
+++ trunk/Configuration/tests/configuration_manager_test.php    2006-06-15 
19:10:42 UTC (rev 3139)
@@ -36,9 +36,9 @@
         $config = ezcConfigurationManager::getInstance();
         $config->init( 'ezcConfigurationIniReader', 'files', array() );
 
-        $this->assertPrivatePropertySame( $config, 'readerClass', 
'ezcConfigurationIniReader' );
-        $this->assertPrivatePropertySame( $config, 'location', 'files' );
-        $this->assertPrivatePropertySame( $config, 'options', array() );
+        $this->assertSame( 'ezcConfigurationIniReader', 
$this->getNonPublicProperty( $config, 'readerClass' ) );
+        $this->assertSame( 'files', $this->getNonPublicProperty( $config, 
'location' ) );
+        $this->assertSame( array(), $this->getNonPublicProperty( $config, 
'options' ) );
     }
 
     public function testInitClassWrongInterface()

Modified: trunk/Configuration/tests/configuration_test.php
===================================================================
--- trunk/Configuration/tests/configuration_test.php    2006-06-15 18:27:22 UTC 
(rev 3138)
+++ trunk/Configuration/tests/configuration_test.php    2006-06-15 19:10:42 UTC 
(rev 3139)
@@ -410,11 +410,11 @@
         $comments = array(
         );
         $configuration = new ezcConfiguration( $settings, $comments );
-        $this->assertPrivatePropertySame( $configuration, 'isModified', false 
);
+        $this->assertSame( false, $this->getNonPublicProperty( $configuration, 
'isModified' ) );
 
         $configuration->setSetting( 'TheOnlyGroup', 'Existing1', 'yes' );
         $configuration->setSetting( 'TheOnlyGroup', 'Existing2', 'yes', 'With 
comment' );
-        $this->assertPrivatePropertySame( $configuration, 'isModified', true );
+        $this->assertSame( true, $this->getNonPublicProperty( $configuration, 
'isModified' ) );
         $this->assertEquals( 'yes', $configuration->getSetting( 
'TheOnlyGroup', 'Existing1' ) );
         $this->assertEquals( 'yes', $configuration->getSetting( 
'TheOnlyGroup', 'Existing2' ) );
         $this->assertEquals( false, $configuration->getComment( 
'TheOnlyGroup', 'Existing1' ) );
@@ -431,11 +431,11 @@
         $comments = array(
         );
         $configuration = new ezcConfiguration( $settings, $comments );
-        $this->assertPrivatePropertySame( $configuration, 'isModified', false 
);
+        $this->assertSame( false, $this->getNonPublicProperty( $configuration, 
'isModified' ) );
 
         $configuration->setSetting( 'TheOnlyGroup', 'New1', 42 );
         $configuration->setSetting( 'TheOnlyGroup', 'New2', 43, 'With comment' 
);
-        $this->assertPrivatePropertySame( $configuration, 'isModified', true );
+        $this->assertSame( true, $this->getNonPublicProperty( $configuration, 
'isModified' ) );
         $this->assertEquals( 42, $configuration->getSetting( 'TheOnlyGroup', 
'New1' ) );
         $this->assertEquals( 43, $configuration->getSetting( 'TheOnlyGroup', 
'New2' ) );
         $this->assertEquals( false, $configuration->getComment( 
'TheOnlyGroup', 'New1' ) );
@@ -452,10 +452,10 @@
         $comments = array(
         );
         $configuration = new ezcConfiguration( $settings, $comments );
-        $this->assertPrivatePropertySame( $configuration, 'isModified', false 
);
+        $this->assertSame( false, $this->getNonPublicProperty( $configuration, 
'isModified' ) );
 
         $configuration->removeSetting( 'TheOnlyGroup', 'Setting1' );
-        $this->assertPrivatePropertySame( $configuration, 'isModified', true );
+        $this->assertSame( true, $this->getNonPublicProperty( $configuration, 
'isModified' ) );
         $this->assertEquals( false, $configuration->hasSetting( 
'TheOnlyGroup', 'Setting1' ) );
     }
 
@@ -707,7 +707,7 @@
         $comments = array(
         );
         $configuration = new ezcConfiguration( $settings, $comments );
-        $this->assertPrivatePropertySame( $configuration, 'isModified', false 
);
+        $this->assertSame( false, $this->getNonPublicProperty( $configuration, 
'isModified' ) );
 
         $configuration->setSettings(
             'TheOnlyGroup',
@@ -715,7 +715,7 @@
             array( false, 'false', 0 ),
             array( 'Comment', null )
         );
-        $this->assertPrivatePropertySame( $configuration, 'isModified', true );
+        $this->assertSame( true, $this->getNonPublicProperty( $configuration, 
'isModified' ) );
         $this->assertEquals(
             array( 'Existing1' => false, 'Existing2' => 'false', 'Existing3' 
=> 0 ),
             $configuration->getSettings( 'TheOnlyGroup', array( 'Existing1', 
'Existing2', 'Existing3' ) )
@@ -735,10 +735,10 @@
         $comments = array(
         );
         $configuration = new ezcConfiguration( $settings, $comments );
-        $this->assertPrivatePropertySame( $configuration, 'isModified', false 
);
+        $this->assertSame( false, $this->getNonPublicProperty( $configuration, 
'isModified' ) );
 
         $configuration->setSettings( 'TheOnlyGroup', array( 'Existing1', 
'Existing2', 'Existing3' ), array( false, 'false', 0 ) );
-        $this->assertPrivatePropertySame( $configuration, 'isModified', true );
+        $this->assertSame( true, $this->getNonPublicProperty( $configuration, 
'isModified' ) );
         $this->assertEquals(
             array( 'Existing1' => false, 'Existing2' => 'false', 'Existing3' 
=> 0 ),
             $configuration->getSettings( 'TheOnlyGroup', array( 'Existing1', 
'Existing2', 'Existing3' ) )
@@ -813,10 +813,10 @@
             )
         );
         $configuration = new ezcConfiguration( $settings, $comments );
-        $this->assertPrivatePropertySame( $configuration, 'isModified', false 
);
+        $this->assertSame( false, $this->getNonPublicProperty( $configuration, 
'isModified' ) );
 
         $configuration->removeSettings( 'TheOnlyGroup', array( 'Existing1' ) );
-        $this->assertPrivatePropertySame( $configuration, 'isModified', true );
+        $this->assertSame( true, $this->getNonPublicProperty( $configuration, 
'isModified' ) );
         $this->assertEquals(
             array( 'Existing2' => 'true', 'Existing3' => 1 ),
             $configuration->getSettingsInGroup( 'TheOnlyGroup' )
@@ -831,11 +831,11 @@
         $comments = array(
         );
         $configuration = new ezcConfiguration( $settings, $comments );
-        $this->assertPrivatePropertySame( $configuration, 'isModified', false 
);
+        $this->assertSame( false, $this->getNonPublicProperty( $configuration, 
'isModified' ) );
 
         $found = $configuration->addGroup( 'TheOnlyGroup', 'A comment' );
-        $this->assertPrivatePropertySame( $configuration, 'isModified', true );
-        $this->assertPrivatePropertySame( $configuration, 'comments', array( 
'TheOnlyGroup' => array( '#' => 'A comment' ) ) );
+        $this->assertSame( true, $this->getNonPublicProperty( $configuration, 
'isModified' ) );
+        $this->assertSame( array( 'TheOnlyGroup' => array( '#' => 'A comment' 
) ), $this->getNonPublicProperty( $configuration, 'comments' ) );
     }
 
     public function testAddGroup2()
@@ -909,7 +909,7 @@
         $configuration = new ezcConfiguration( $settings, $comments );
         $configuration->removeGroup( 'TheOnlyGroup' );
         $this->assertEquals( false, $configuration->hasGroup( 'TheOnlyGroup' ) 
);
-        $this->assertPrivatePropertySame( $configuration, 'isModified', true );
+        $this->assertSame( true, $this->getNonPublicProperty( $configuration, 
'isModified' ) );
     }
 
     public function testRemoveGroup2()
@@ -946,7 +946,7 @@
         $configuration->removeAllSettings();
         $this->assertEquals( false, $configuration->hasGroup( 'TheOnlyGroup' ) 
);
         $this->assertEquals( false, $configuration->hasGroup( 
'TheSecondOnlyGroup' ) );
-        $this->assertPrivatePropertySame( $configuration, 'isModified', true );
+        $this->assertSame( true, $this->getNonPublicProperty( $configuration, 
'isModified' ) );
     }
 
     public function testIsModified()
@@ -956,11 +956,11 @@
         $comments = array(
         );
         $configuration = new ezcConfiguration( $settings, $comments );
-        $this->assertPrivatePropertySame( $configuration, 'isModified', false 
);
+        $this->assertSame( false, $this->getNonPublicProperty( $configuration, 
'isModified' ) );
         $this->assertEquals( false, $configuration->isModified() );
 
         $found = $configuration->addGroup( 'TheOnlyGroup', 'A comment' );
-        $this->assertPrivatePropertySame( $configuration, 'isModified', true );
+        $this->assertSame( true, $this->getNonPublicProperty( $configuration, 
'isModified' ) );
         $this->assertEquals( true, $configuration->isModified() );
     }
 

Modified: trunk/Graph/tests/chart_test.php
===================================================================
--- trunk/Graph/tests/chart_test.php    2006-06-15 18:27:22 UTC (rev 3138)
+++ trunk/Graph/tests/chart_test.php    2006-06-15 19:10:42 UTC (rev 3139)
@@ -75,7 +75,7 @@
             'Background is not an ezcGraphChartElementBackgroundImage.'
         );
 
-        $this->assertProtectedPropertySame( $background, 'source', 
$this->basePath . $this->testFiles['jpeg'] );
+        $this->assertSame( $this->basePath . $this->testFiles['jpeg'], 
$this->getNonPublicProperty( $background, 'source' ) );
     }
 
     public function testSetOptionsInvalidBackgroundImage()
@@ -135,7 +135,7 @@
         $pieChart = ezcGraph::create( 'Pie' );
         $pieChart->options->borderWidth = 3;
 
-        $this->assertProtectedPropertySame( $pieChart->options, 'borderWidth', 
3 );
+        $this->assertSame( 3, $this->getNonPublicProperty( $pieChart->options, 
'borderWidth' ) );
     }
 
     public function testSetOptionsUnknown()

Modified: trunk/Template/tests/compiled_code_test.php
===================================================================
--- trunk/Template/tests/compiled_code_test.php 2006-06-15 18:27:22 UTC (rev 
3138)
+++ trunk/Template/tests/compiled_code_test.php 2006-06-15 19:10:42 UTC (rev 
3139)
@@ -46,10 +46,10 @@
     {
         $conf = new ezcTemplateCompiledCode( '8efb', 
$this->templateCompiledPath . '8efb.php' );
 
-        self::assertPropertySame( $conf, 'identifier', "8efb" );
-        self::assertPropertySame( $conf, 'path',       
$this->templateCompiledPath . '8efb.php' );
-        self::assertPropertySame( $conf, 'context',    null );
-        self::assertPropertySame( $conf, 'template',    null );
+        $this->assertSame( '8efb', $this->getNonPublicProperty( $conf, 
'identifier' ) );
+        $this->assertSame( $this->templateCompiledPath . '8efb.php', 
$this->getNonPublicProperty( $conf, 'path' ) );
+        $this->assertSame( null, $this->getNonPublicProperty( $conf, 'context' 
) );
+        $this->assertSame( null, $this->getNonPublicProperty( $conf, 
'template' ) );
     }
 
     /**

Modified: trunk/Template/tests/configuration_test.php
===================================================================
--- trunk/Template/tests/configuration_test.php 2006-06-15 18:27:22 UTC (rev 
3138)
+++ trunk/Template/tests/configuration_test.php 2006-06-15 19:10:42 UTC (rev 
3139)
@@ -30,16 +30,16 @@
     {
         $conf = new ezcTemplateConfiguration();
 
-        self::assertPropertySame( $conf, 'templatePath',        "." );
-        self::assertPropertySame( $conf, 'compilePath',        "." );
+        $this->assertSame( '.', $this->getNonPublicProperty( $conf, 
'templatePath' ) );
+        $this->assertSame( '.', $this->getNonPublicProperty( $conf, 
'compilePath' ) );
     }
 
     public function testInit()
     {
         $conf = new ezcTemplateConfiguration( 'templates', 'compiled' );
 
-        self::assertPropertySame( $conf, 'templatePath',        "templates" );
-        self::assertPropertySame( $conf, 'compilePath',        "compiled" );
+        $this->assertSame( 'templates', $this->getNonPublicProperty( $conf, 
'templatePath' ) );
+        $this->assertSame( 'compiled', $this->getNonPublicProperty( $conf, 
'compilePath' ) );
     }
 
     public function testInvalidProperties()

Modified: trunk/UnitTest/src/test/case.php
===================================================================
--- trunk/UnitTest/src/test/case.php    2006-06-15 18:27:22 UTC (rev 3138)
+++ trunk/UnitTest/src/test/case.php    2006-06-15 19:10:42 UTC (rev 3139)
@@ -118,56 +118,6 @@
     }
 
     /**
-     * Checks if the value of a private property has the expected value
-     *
-     * Checks if the private property $propertyName in object $object is a
-     * private property and whether it matches the expected value.  Before
-     * fetching the value it checks that $object is an object and that the
-     * property exists.
-     *
-     * @param $object The object containing the property $propertyName.
-     * @param $propertyName The name of the property to access.
-     * @param $expectedValue The value the property is expected to have.
-     *
-     * @see assertSame(), assertPropertySame(), assertProtectedPropertySame()
-     */
-    public function assertPrivatePropertySame( $object, $propertyName, 
$expectedValue )
-    {
-        self::assertTrue( is_object( $object ),
-                          "Parameter <\$object> must be an object, got: <" . 
gettype( $object ) . ">" );
-        $data = (array) $object;
-        self::assertSame( true, isset( $data["\0" . get_class( $object ) . 
"\0" . $propertyName] ),
-                          "Property <$propertyName> is not a private property 
on object <" . get_class( $object ) . ">." );
-        self::assertSame( $expectedValue, $data["\0" . get_class( $object ) . 
"\0" . $propertyName],
-                          "Property <$propertyName> does not return correct 
value from object <" . get_class( $object ) . ">." );
-    }
-
-    /**
-     * Checks if the value of a protected property has the expected value
-     *
-     * Checks if the protected property $propertyName in object $object is a
-     * protected property and whether it matches the expected value.  Before
-     * fetching the value it checks that $object is an object and that the
-     * property exists.
-     *
-     * @param $object The object containing the property $propertyName.
-     * @param $propertyName The name of the property to access.
-     * @param $expectedValue The value the property is expected to have.
-     *
-     * @see assertSame(), assertPropertySame(), assertPrivatePropertySame()
-     */
-    public function assertProtectedPropertySame( $object, $propertyName, 
$expectedValue )
-    {
-        self::assertTrue( is_object( $object ),
-                          "Parameter <\$object> must be an object, got: <" . 
gettype( $object ) . ">" );
-        $data = (array) $object;
-        self::assertSame( true, isset( $data["\0*\0" . $propertyName] ),
-                          "Property <$propertyName> is not a protected 
property on object <" . get_class( $object ) . ">." );
-        self::assertSame( $expectedValue, $data["\0*\0" . $propertyName],
-                          "Property <$propertyName> does not return correct 
value from object <" . get_class( $object ) . ">." );
-    }
-
-    /**
      * Checks if the property $propertyName in object $object contains the 
correct value $expectedValue.
      * Before fetching the value it checks that $object is an object and that 
the property exists.
      *

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

Reply via email to