Author: caefer
Date: 2010-03-23 22:03:03 +0100 (Tue, 23 Mar 2010)
New Revision: 28740
Modified:
plugins/sfImageTransformExtraPlugin/trunk/lib/source/sfImageSourceDoctrine.class.php
plugins/sfImageTransformExtraPlugin/trunk/test/fixtures/model/TestRecord.php
plugins/sfImageTransformExtraPlugin/trunk/test/unit/lib/source/sfImageSourceDoctrineTest.php
Log:
* a little more coverage yet again
Modified:
plugins/sfImageTransformExtraPlugin/trunk/lib/source/sfImageSourceDoctrine.class.php
===================================================================
---
plugins/sfImageTransformExtraPlugin/trunk/lib/source/sfImageSourceDoctrine.class.php
2010-03-23 20:54:07 UTC (rev 28739)
+++
plugins/sfImageTransformExtraPlugin/trunk/lib/source/sfImageSourceDoctrine.class.php
2010-03-23 21:03:03 UTC (rev 28740)
@@ -154,8 +154,12 @@
}
$url = parse_url($path);
- if(!($table = Doctrine::getTable($url['host'])))
+ try
{
+ $table = Doctrine::getTable($url['host']);
+ }
+ catch(Doctrine_Exception $e)
+ {
throw new sfError404Exception('Could not find Doctrine table
"'.$url['host'].'"');
}
Modified:
plugins/sfImageTransformExtraPlugin/trunk/test/fixtures/model/TestRecord.php
===================================================================
---
plugins/sfImageTransformExtraPlugin/trunk/test/fixtures/model/TestRecord.php
2010-03-23 20:54:07 UTC (rev 28739)
+++
plugins/sfImageTransformExtraPlugin/trunk/test/fixtures/model/TestRecord.php
2010-03-23 21:03:03 UTC (rev 28740)
@@ -47,6 +47,12 @@
{
public function find($id)
{
- return new TestRecord();
+ switch ($id)
+ {
+ case 1:
+ return new TestRecord();
+ default:
+ return null;
+ }
}
}
Modified:
plugins/sfImageTransformExtraPlugin/trunk/test/unit/lib/source/sfImageSourceDoctrineTest.php
===================================================================
---
plugins/sfImageTransformExtraPlugin/trunk/test/unit/lib/source/sfImageSourceDoctrineTest.php
2010-03-23 20:54:07 UTC (rev 28739)
+++
plugins/sfImageTransformExtraPlugin/trunk/test/unit/lib/source/sfImageSourceDoctrineTest.php
2010-03-23 21:03:03 UTC (rev 28740)
@@ -61,6 +61,24 @@
fclose($fh);
}
+ /**
+ * @expectedException sfError404Exception
+ */
+ public function testFailedStream_open()
+ {
+ $testSourceUri =
sfImageSourceDoctrine::buildURIfromParameters(array('type' => 'DoesNotExist',
'attribute' => 'file', 'id' => 1));
+ $fh = fopen($testSourceUri, 'r');
+ }
+
+ /**
+ * @expectedException sfError404Exception
+ */
+ public function testNotFoundStream_open()
+ {
+ $testSourceUri =
sfImageSourceDoctrine::buildURIfromParameters(array('type' => 'TestRecord',
'attribute' => 'file', 'id' => 2));
+ $fh = fopen($testSourceUri, 'r');
+ }
+
public function testStream_open()
{
$fh = fopen($this->testSourceUri, 'r');
@@ -87,6 +105,14 @@
$this->assertTrue(is_array(stat($this->testSourceUri)));
}
+ /**
+ * @expectedException InvalidArgumentException
+ */
+ public function testFailedBuildURIfromParameters()
+ {
+ $this->assertEquals('sfImageSource://TestRecord/file#1',
sfImageSourceDoctrine::buildURIfromParameters(array()));
+ }
+
public function testBuildURIfromParameters()
{
$this->assertEquals('sfImageSource://TestRecord/file#1',
sfImageSourceDoctrine::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.