From: Chuck Hagenbuch Date: Wed, 30 Sep 2009 04:15:39 +0000 (-0400) Subject: refactor Horde_Feed tests for recent changes X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=0895825aae49e3e41dd4eb5cfa254749c1668096;p=horde.git refactor Horde_Feed tests for recent changes --- diff --git a/framework/Feed/test/Horde/Feed/AllTests.php b/framework/Feed/test/Horde/Feed/AllTests.php index 327592eb2..625cff048 100644 --- a/framework/Feed/test/Horde/Feed/AllTests.php +++ b/framework/Feed/test/Horde/Feed/AllTests.php @@ -8,11 +8,11 @@ if (!defined('PHPUnit_MAIN_METHOD')) { define('PHPUnit_MAIN_METHOD', 'Horde_Feed_AllTests::main'); } -require_once 'PHPUnit/Framework/TestSuite.php'; +require_once 'PHPUnit/Framework.php'; require_once 'PHPUnit/TextUI/TestRunner.php'; -class Horde_Feed_AllTests { - +class Horde_Feed_AllTests +{ public static function main() { PHPUnit_TextUI_TestRunner::run(self::suite()); @@ -20,6 +20,10 @@ class Horde_Feed_AllTests { public static function suite() { + if (!spl_autoload_functions()) { + spl_autoload_register(create_function('$class', '$filename = str_replace(array(\'::\', \'_\'), \'/\', $class); include "$filename.php";')); + } + $suite = new PHPUnit_Framework_TestSuite('Horde Framework - Horde_Feed'); $basedir = dirname(__FILE__); diff --git a/framework/Feed/test/Horde/Feed/AtomPublishingTest.php b/framework/Feed/test/Horde/Feed/AtomPublishingTest.php index e049fbf3d..fa75e224e 100644 --- a/framework/Feed/test/Horde/Feed/AtomPublishingTest.php +++ b/framework/Feed/test/Horde/Feed/AtomPublishingTest.php @@ -17,30 +17,25 @@ class Horde_Feed_AtomPublishingTest extends PHPUnit_Framework_TestCase { $this->uri = 'http://example.com/Feed'; } - public function tearDown() - { - Horde_Feed::setHttpClient(new Horde_Http_Client); - } - public function testPost() { - $mock = new Horde_Http_Client_Mock; - $mock->setResponse(new Horde_Http_Client_Response('', fopen(dirname(__FILE__) . '/fixtures/AtomPublishingTest-created-entry.xml', 'r'), array('HTTP/1.1 201'))); - Horde_Feed::setHttpClient($mock); + $mock = new Horde_Http_Request_Mock(); + $mock->setResponse(new Horde_Http_Response_Mock('', fopen(dirname(__FILE__) . '/fixtures/AtomPublishingTest-created-entry.xml', 'r'), array('HTTP/1.1 201'))); + $httpClient = new Horde_Http_Client(array('request' => $mock)); - $entry = new Horde_Feed_Entry_Atom; + $entry = new Horde_Feed_Entry_Atom(null, $httpClient); - /* Give the entry its initial values. */ + // Give the entry its initial values. $entry->title = 'Entry 1'; $entry->content = '1.1'; $entry->content['type'] = 'text'; - /* Do the initial post. The base feed URI is the same as the - * POST URI, so just supply save() with that. */ + // Do the initial post. The base feed URI is the same as the + // POST URI, so just supply save() with that. $entry->save($this->uri); - /* $entry will be filled in with any elements returned by the - * server (id, updated, link rel="edit", etc). */ + // $entry will be filled in with any elements returned by the + // server (id, updated, link rel="edit", etc). $this->assertEquals('1', $entry->id(), 'Expected id to be 1'); $this->assertEquals('Entry 1', $entry->title(), 'Expected title to be "Entry 1"'); $this->assertEquals('1.1', $entry->content(), 'Expected content to be "1.1"'); @@ -51,26 +46,26 @@ class Horde_Feed_AtomPublishingTest extends PHPUnit_Framework_TestCase { public function testEdit() { - $mock = new Horde_Http_Client_Mock; - $mock->setResponse(new Horde_Http_Client_Response('', fopen(dirname(__FILE__) . '/fixtures/AtomPublishingTest-updated-entry.xml', 'r'), array('HTTP/1.1 200'))); - Horde_Feed::setHttpClient($mock); + $mock = new Horde_Http_Request_Mock(); + $mock->setResponse(new Horde_Http_Response_Mock('', fopen(dirname(__FILE__) . '/fixtures/AtomPublishingTest-updated-entry.xml', 'r'), array('HTTP/1.1 200'))); + $httpClient = new Horde_Http_Client(array('request' => $mock)); - /* The base feed URI is the same as the POST URI, so just supply the - * Horde_Feed_Entry_Atom object with that. */ + // The base feed URI is the same as the POST URI, so just supply the + // Horde_Feed_Entry_Atom object with that. $contents = file_get_contents(dirname(__FILE__) . '/fixtures/AtomPublishingTest-before-update.xml'); - $entry = new Horde_Feed_Entry_Atom($contents, $this->uri); + $entry = new Horde_Feed_Entry_Atom($contents, $httpClient); - /* Initial state. */ + // Initial state. $this->assertEquals('2005-05-23T16:26:00-08:00', $entry->updated(), 'Initial state of updated timestamp does not match'); $this->assertEquals('http://example.com/Feed/1/1/', $entry->link('edit'), 'Initial state of edit link does not match'); - /* Just change the entry's properties directly. */ + // Just change the entry's properties directly. $entry->content = '1.2'; - /* Then save the changes. */ + // Then save the changes. $entry->save(); - /* New state. */ + // New state. $this->assertEquals('1.2', $entry->content(), 'Content change did not stick'); $this->assertEquals('2005-05-23T16:27:00-08:00', $entry->updated(), 'New updated link is not correct'); $this->assertEquals('http://example.com/Feed/1/2/', $entry->link('edit'), 'New edit link is not correct');