Permalink
Browse files

Updated behavior when setting formatter in writers which doesn't supp…

…ort formatting.

Do nothing instead of throwing an exception
  • Loading branch information...
stefankleff committed Oct 15, 2012
1 parent d73ba86 commit 66aa0e63bff0210160dcd8000d4cf303b1adbb1c
@@ -248,12 +248,11 @@ public function reset()
* Fomatters must be set on the wrapped writer.
*
* @param string|Formatter\FormatterInterface $formatter
- * @return void
- * @throws Zend\Log\Exception\InvalidArgumentException
+ * @return WriterInterface
*/
public function setFormatter($formatter)
{
- throw new Exception\InvalidArgumentException(get_class() . ' does not support formatting');
+ return $this->writer;
}
/**
@@ -90,12 +90,11 @@ public function __construct($mongo, $database, $collection, array $saveOptions =
* This writer does not support formatting.
*
* @param string|Zend\Log\Formatter\FormatterInterface $formatter
- * @return void
- * @throws Zend\Log\Exception\InvalidArgumentException
+ * @return WriterInterface
*/
public function setFormatter($formatter)
{
- throw new InvalidArgumentException(get_class() . ' does not support formatting');
+ return $this;
}
/**
@@ -72,4 +72,13 @@ public function testConstructorOptions()
$this->assertInstanceOf('Zend\Log\Filter\Priority', $filters[0]);
$this->assertAttributeEquals(3, 'priority', $filters[0]);
}
+
+ public function testFormattingIsNotSupported()
+ {
+ $options = array('writer' => 'mock', 'priority' => 3);
+ $writer = new FingersCrossedWriter($options);
+
+ $writer->setFormatter($this->getMock('Zend\Log\Formatter\FormatterInterface'));
+ $this->assertAttributeEmpty('formatter', $writer);
+ }
}
@@ -48,14 +48,12 @@ public function setUp()
->will($this->returnValue($this->mongoCollection));
}
- /**
- * @expectedException Zend\Log\Exception\InvalidArgumentException
- */
public function testFormattingIsNotSupported()
{
$writer = new MongoDBWriter($this->mongo, $this->database, $this->collection);
$writer->setFormatter($this->getMock('Zend\Log\Formatter\FormatterInterface'));
+ $this->assertAttributeEmpty('formatter', $writer);
}
public function testWriteWithDefaultSaveOptions()

0 comments on commit 66aa0e6

Please sign in to comment.