Author: caefer
Date: 2010-03-22 13:39:40 +0100 (Mon, 22 Mar 2010)
New Revision: 28669
Modified:
plugins/sfImageTransformExtraPlugin/trunk/lib/source/sfImageSourceHTTP.class.php
plugins/sfImageTransformExtraPlugin/trunk/test/unit/lib/source/sfImageSourceHTTPTest.php
Log:
Unit Tests for sfImageSourceHTTP are green again
Modified:
plugins/sfImageTransformExtraPlugin/trunk/lib/source/sfImageSourceHTTP.class.php
===================================================================
---
plugins/sfImageTransformExtraPlugin/trunk/lib/source/sfImageSourceHTTP.class.php
2010-03-22 12:21:06 UTC (rev 28668)
+++
plugins/sfImageTransformExtraPlugin/trunk/lib/source/sfImageSourceHTTP.class.php
2010-03-22 12:39:40 UTC (rev 28669)
@@ -132,7 +132,7 @@
// all params must be given
if ($diff = array_diff(array('protocol', 'domain', 'filepath'),
array_keys($parameters)))
{
- throw new InvalidArgumentException('The sf_image for image_source "HTTP"
route has some missing mandatory parameters (url).');
+ throw new InvalidArgumentException(sprintf('The sf_image for
image_source "HTTP" route has some missing mandatory parameters (%s).',
implode(', ', $diff)));
}
return sprintf('sfImageSource://%s/%s#%s', $parameters['protocol'],
$parameters['domain'], $parameters['filepath']);
Modified:
plugins/sfImageTransformExtraPlugin/trunk/test/unit/lib/source/sfImageSourceHTTPTest.php
===================================================================
---
plugins/sfImageTransformExtraPlugin/trunk/test/unit/lib/source/sfImageSourceHTTPTest.php
2010-03-22 12:21:06 UTC (rev 28668)
+++
plugins/sfImageTransformExtraPlugin/trunk/test/unit/lib/source/sfImageSourceHTTPTest.php
2010-03-22 12:39:40 UTC (rev 28669)
@@ -25,9 +25,16 @@
*/
class sfImageSourceHTTPTest extends PHPUnit_Framework_TestCase
{
+ private $testSourceUri = null;
+ private $testParameters = array(
+ 'protocol' => 'http',
+ 'domain' => 'localhost',
+ 'filepath' => 'test/image.gif'
+ );
+
public function testStream_close()
{
- $fh = fopen('sfImageSource://TestFile/file#1', 'r');
+ $fh = fopen($this->testSourceUri, 'r');
$this->assertTrue(is_resource($fh));
fclose($fh);
$this->assertFalse(is_resource($fh));
@@ -35,7 +42,7 @@
public function testStream_eof()
{
- $fh = fopen('sfImageSource://TestFile/file#1', 'r');
+ $fh = fopen($this->testSourceUri, 'r');
$this->assertFalse(feof($fh));
while(!feof($fh))
{
@@ -47,41 +54,40 @@
public function testStream_flush()
{
- $fh = fopen('sfImageSource://TestFile/file#1', 'r');
+ $fh = fopen($this->testSourceUri, 'r');
$this->assertTrue(fflush($fh));
fclose($fh);
}
public function testStream_open()
{
- $fh = fopen('sfImageSource://TestFile/file#1', 'r');
+ $fh = fopen($this->testSourceUri, 'r');
$this->assertType(PHPUnit_Framework_Constraint_IsType::TYPE_RESOURCE, $fh);
fclose($fh);
}
public function testStream_read()
{
- $fh = fopen('sfImageSource://TestFile/file#1', 'r');
+ $fh = fopen($this->testSourceUri, 'r');
$this->assertEquals(10, strlen(fread($fh, 10)));
fclose($fh);
}
public function testStream_stat()
{
- $fh = fopen('sfImageSource://TestFile/file#1', 'r');
+ $fh = fopen($this->testSourceUri, 'r');
$this->assertType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY,
fstat($fh));
fclose($fh);
}
public function testUrl_stat()
{
- $this->assertType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY,
stat('sfImageSource://TestFile/file#1'));
+ $this->assertType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY,
stat($this->testSourceUri));
}
- public function testbuildURIfromParameters()
+ public function testBuildURIfromParameters()
{
- $parameters = array('type' => 'TestFile', 'id' => 1, 'attribute' =>
'file');
- $this->assertEquals('http://localhost/TestFile/file/1',
sfImageSourceHTTP::buildURIfromParameters($parameters));
+ $this->assertEquals('sfImageSource://http/localhost#test/image.gif',
sfImageSourceHTTP::buildURIfromParameters($this->testParameters));
}
protected function setUp()
@@ -92,5 +98,7 @@
}
sfConfig::set('thumbnailing_source_image_stream_param', array('url_schema'
=> 'http://localhost/%type/%attribute/%id'));
stream_wrapper_register('sfImageSource', 'sfImageSourceHTTP') or
die('Failed to register protocol..');
+
+ $this->testSourceUri =
sfImageSourceHTTP::buildURIfromParameters($this->testParameters);
}
}
--
You received this message because you are subscribed to the Google Groups
"symfony SVN" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/symfony-svn?hl=en.