Author: caefer
Date: 2010-03-23 19:49:31 +0100 (Tue, 23 Mar 2010)
New Revision: 28734
Modified:
plugins/sfImageTransformExtraPlugin/trunk/lib/transforms/sfImageRoundedCornersGD.class.php
plugins/sfImageTransformExtraPlugin/trunk/test/unit/lib/source/sfImageSourceHTTPTest.php
plugins/sfImageTransformExtraPlugin/trunk/test/unit/lib/source/sfImageSourceMockTest.php
plugins/sfImageTransformExtraPlugin/trunk/test/unit/lib/transforms/sfImageRoundedCornersGDTest.php
Log:
yet again some more test coverage
Modified:
plugins/sfImageTransformExtraPlugin/trunk/lib/transforms/sfImageRoundedCornersGD.class.php
===================================================================
---
plugins/sfImageTransformExtraPlugin/trunk/lib/transforms/sfImageRoundedCornersGD.class.php
2010-03-23 18:18:36 UTC (rev 28733)
+++
plugins/sfImageTransformExtraPlugin/trunk/lib/transforms/sfImageRoundedCornersGD.class.php
2010-03-23 18:49:31 UTC (rev 28734)
@@ -106,7 +106,7 @@
private function getMask($w, $h)
{
- // Create a mask png image of the area you want in the circle/ellipse (a
‘magicpink’ image with a black shape on it, with black set to the colour of
alpha transparency) - $mask
+ // Create a mask png image of the area you want in the circle/ellipse (a
'magicpink' image with a black shape on it, with black set to the colour of
alpha transparency) - $mask
$mask = imagecreatetruecolor($w, $h);
imagealphablending($mask, true);
// Set the masking colours
@@ -140,33 +140,4 @@
imagefilledellipse($im, $cx - $rad, $cy - $rad, $rad * 2, $dia, $col);
imagefilledellipse($im, $cx - $rad, $y + $rad, $rad * 2, $dia, $col);
}
-
- /**
- * Callback function to extend/alter parameters as given in your
thumbnailing.yml.
- *
- * This callback adds the resources path to an overlay image
- *
- * @param sfImage $sourceImage The original image
- * @param array $parameters Configured parameters for this transformation
- * @return array $parameters Extended/altered parameters
- */
- public static function prepareParameters($sourceImage, $parameters)
- {
- if (!array_key_exists('overlay', $parameters))
- {
- return $parameters;
- }
-
- $user_resources_dir = sfConfig::get('sf_data_dir') . '/resources';
- $plugin_resources_dir = sfConfig::get('sf_plugins_dir') .
'/sfImageTransformExtraPlugin/data/example-resources';
- if (file_exists($user_resources_dir . '/' . $parameters['overlay']))
- {
- $parameters['overlay'] = new sfImage($user_resources_dir . '/' .
$parameters['overlay']);
- }
- else if (file_exists($plugin_resources_dir . '/' . $parameters['overlay']))
- {
- $parameters['overlay'] = new sfImage($plugin_resources_dir . '/' .
$parameters['overlay']);
- }
- return $parameters;
- }
}
Modified:
plugins/sfImageTransformExtraPlugin/trunk/test/unit/lib/source/sfImageSourceHTTPTest.php
===================================================================
---
plugins/sfImageTransformExtraPlugin/trunk/test/unit/lib/source/sfImageSourceHTTPTest.php
2010-03-23 18:18:36 UTC (rev 28733)
+++
plugins/sfImageTransformExtraPlugin/trunk/test/unit/lib/source/sfImageSourceHTTPTest.php
2010-03-23 18:49:31 UTC (rev 28734)
@@ -85,6 +85,14 @@
$this->assertType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY,
stat($this->testSourceUri));
}
+ /**
+ * @expectedException InvalidArgumentException
+ */
+ public function testFailedBuildURIfromParameters()
+ {
+ $this->assertEquals('sfImageSource://http/localhost#test/image.gif',
sfImageSourceHTTP::buildURIfromParameters(array()));
+ }
+
public function testBuildURIfromParameters()
{
$this->assertEquals('sfImageSource://http/localhost#test/image.gif',
sfImageSourceHTTP::buildURIfromParameters($this->testParameters));
Modified:
plugins/sfImageTransformExtraPlugin/trunk/test/unit/lib/source/sfImageSourceMockTest.php
===================================================================
---
plugins/sfImageTransformExtraPlugin/trunk/test/unit/lib/source/sfImageSourceMockTest.php
2010-03-23 18:18:36 UTC (rev 28733)
+++
plugins/sfImageTransformExtraPlugin/trunk/test/unit/lib/source/sfImageSourceMockTest.php
2010-03-23 18:49:31 UTC (rev 28734)
@@ -27,7 +27,7 @@
{
public function testStream_close()
{
- $fh = fopen('sfImageSource://TestFile/file#1', 'r');
+ $fh = fopen('sfImageSource://mock', 'r');
$this->assertTrue(is_resource($fh));
fclose($fh);
$this->assertFalse(is_resource($fh));
@@ -35,7 +35,7 @@
public function testStream_eof()
{
- $fh = fopen('sfImageSource://TestFile/file#1', 'r');
+ $fh = fopen('sfImageSource://mock', 'r');
$this->assertFalse(feof($fh));
while(!feof($fh))
{
@@ -47,37 +47,42 @@
public function testStream_flush()
{
- $fh = fopen('sfImageSource://TestFile/file#1', 'r');
+ $fh = fopen('sfImageSource://mock', 'r');
$this->assertTrue(fflush($fh));
fclose($fh);
}
public function testStream_open()
{
- $fh = fopen('sfImageSource://TestFile/file#1', 'r');
+ $fh = fopen('sfImageSource://mock', 'r');
$this->assertTrue(is_resource($fh));
fclose($fh);
}
public function testStream_read()
{
- $fh = fopen('sfImageSource://TestFile/file#1', 'r');
+ $fh = fopen('sfImageSource://mock', 'r');
$this->assertEquals(10, strlen(fread($fh, 10)));
fclose($fh);
}
public function testStream_stat()
{
- $fh = fopen('sfImageSource://TestFile/file#1', 'r');
+ $fh = fopen('sfImageSource://mock', 'r');
$this->assertTrue(is_array(fstat($fh)));
fclose($fh);
}
public function testUrl_stat()
{
- $this->assertTrue(is_array(stat('sfImageSource://TestFile/file#1')));
+ $this->assertTrue(is_array(stat('sfImageSource://mock')));
}
+ public function testBuildURIfromParameters()
+ {
+ $this->assertEquals('sfImageSource://mock',
sfImageSourceMock::buildURIfromParameters(array()));
+ }
+
protected function setUp()
{
if(in_array('sfImageSource', stream_get_wrappers()))
Modified:
plugins/sfImageTransformExtraPlugin/trunk/test/unit/lib/transforms/sfImageRoundedCornersGDTest.php
===================================================================
---
plugins/sfImageTransformExtraPlugin/trunk/test/unit/lib/transforms/sfImageRoundedCornersGDTest.php
2010-03-23 18:18:36 UTC (rev 28733)
+++
plugins/sfImageTransformExtraPlugin/trunk/test/unit/lib/transforms/sfImageRoundedCornersGDTest.php
2010-03-23 18:49:31 UTC (rev 28734)
@@ -30,4 +30,12 @@
$transformation = new sfImageRoundedCornersGD(null, false);
$this->assertType('sfImageRoundedCornersGD', $transformation);
}
+
+ public function testTransform()
+ {
+ $img1 = new
sfImage(dirname(__FILE__).'/../../../../data/example-resources/overlays/logo.png');
+ $this->assertType('sfImage', $img1->roundedCorners(10));
+ $img2 = new sfImage(dirname(__FILE__).'/../../../../data/caefer.jpg');
+ $this->assertType('sfImage', $img2->roundedCorners(10), '#FF0000');
+ }
}
--
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.