Change factory handling.
authorGunnar Wrobel <p@rdus.de>
Thu, 9 Dec 2010 10:02:52 +0000 (11:02 +0100)
committerGunnar Wrobel <p@rdus.de>
Mon, 13 Dec 2010 10:17:10 +0000 (11:17 +0100)
framework/Kolab_Format/test/Horde/Kolab/Format/Integration/EventTest.php
framework/Kolab_Format/test/Horde/Kolab/Format/Integration/MimeAttrTest.php
framework/Kolab_Format/test/Horde/Kolab/Format/Integration/RecurrenceTest.php
framework/Kolab_Format/test/Horde/Kolab/Format/Integration/TaskTest.php
framework/Kolab_Format/test/Horde/Kolab/Format/TestCase.php

index 21238ba..561f918 100644 (file)
@@ -42,7 +42,7 @@ extends Horde_Kolab_Format_TestCase
      */
     public function testIssue3525()
     {
-        $xml = $this->factory('XML', 'event');
+        $xml = $this->getFactory()->create('XML', 'event');
 
         // Load XML
         $event  = file_get_contents(dirname(__FILE__)
index 883562c..656ec06 100644 (file)
@@ -42,7 +42,7 @@ extends Horde_Kolab_Format_TestCase
      */
     public function testGetName()
     {
-        $format = $this->factory('XML', 'contact');
+        $format = $this->getFactory()->create('XML', 'contact');
         $this->assertEquals('kolab.xml', $format->getName());
     }
 
@@ -53,7 +53,7 @@ extends Horde_Kolab_Format_TestCase
      */
     public function testMimeType()
     {
-        $format = $this->factory('XML', 'contact');
+        $format = $this->getFactory()->create('XML', 'contact');
         $this->assertEquals('application/x-vnd.kolab.contact',
                             $format->getMimeType());
     }
@@ -65,7 +65,7 @@ extends Horde_Kolab_Format_TestCase
      */
     public function testGetDisposition()
     {
-        $format = $this->factory('XML', 'contact');
+        $format = $this->getFactory()->create('XML', 'contact');
         $this->assertEquals('attachment', $format->getDisposition());
     }
 }
index 0cb5dd6..91d7e71 100644 (file)
@@ -63,13 +63,13 @@ extends Horde_Kolab_Format_TestCase
      */
     public function testBug6388()
     {
-        $xml = $this->factory('XML', 'event');
+        $xml = $this->getFactory()->create('XML', 'event');
 
         // Load XML
         $recur = file_get_contents(dirname(__FILE__) . '/fixtures/recur.xml');
 
         // Load XML
-        $xml   = $this->factory('XML', 'event');
+        $xml   = $this->getFactory()->create('XML', 'event');
         $recur = file_get_contents(dirname(__FILE__) . '/fixtures/recur_fail.xml');
 
         // Check that the xml fails because of a missing interval value
@@ -89,7 +89,7 @@ extends Horde_Kolab_Format_TestCase
      */
     public function testExceptions()
     {
-        $xml = $this->factory('XML', 'event');
+        $xml = $this->getFactory()->create('XML', 'event');
 
         // Load XML
         $recur = file_get_contents(dirname(__FILE__) . '/fixtures/recur.xml');
@@ -122,7 +122,7 @@ extends Horde_Kolab_Format_TestCase
      */
     public function testCompletions()
     {
-        $xml = $this->factory('XML', 'event');
+        $xml = $this->getFactory()->create('XML', 'event');
 
         $r = new Horde_Date_Recurrence(0);
         $r->setRecurType(Horde_Date_Recurrence::RECUR_DAILY);
index 0231a8a..8f1c524 100644 (file)
@@ -41,7 +41,7 @@ extends Horde_Kolab_Format_TestCase
      */
     public function testBasicTask()
     {
-        $xml = $this->factory('XML', 'task');
+        $xml = $this->getFactory()->create('XML', 'task');
 
         // Load XML
         $task = file_get_contents(dirname(__FILE__) . '/../fixtures/task.xml');
index 818848c..3993ba1 100644 (file)
 class Horde_Kolab_Format_TestCase
 extends PHPUnit_Framework_TestCase
 {
-    public function factory(
-        $format_type = '', $object_type = '', $params = null
-    ) {
-        $factory = new Horde_Kolab_Format_Factory();
-        return $factory->create($format_type, $object_type, $params);
+    private $_factory;
+
+    protected function getFactory()
+    {
+        if ($this->_factory === null) {
+            $this->_factory = new Horde_Kolab_Format_Factory();
+        }
+        return $this->_factory;
     }
 }