1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-08-01 10:50:21 +02:00

Removed obsolete var_export(). Made construction argument validation tests simpler and more readable.

This commit is contained in:
kolja
2016-01-15 20:21:02 +01:00
parent 1be08de729
commit f13011e03e
2 changed files with 4 additions and 15 deletions

View File

@@ -115,7 +115,7 @@ class ProcessHandler extends AbstractProcessingHandler
$errors = $this->readProcessErrors(); $errors = $this->readProcessErrors();
if (empty($errors) === false) { if (empty($errors) === false) {
throw new \UnexpectedValueException('Errors while writing to process: ' . var_export($errors, true)); throw new \UnexpectedValueException(sprintf('Errors while writing to process: %s', $errors));
} }
} }

View File

@@ -71,20 +71,14 @@ class ProcessHandlerTest extends TestCase
} }
/** /**
*
* @dataProvider invalidCommandProvider * @dataProvider invalidCommandProvider
* @param mixed $invalidCommand * @param mixed $invalidCommand
* @covers Monolog\Handler\ProcessHandler::guardAgainstInvalidCommand * @covers Monolog\Handler\ProcessHandler::guardAgainstInvalidCommand
*/ */
public function testConstructWithInvalidCommandThrowsInvalidArgumentException($invalidCommand) public function testConstructWithInvalidCommandThrowsInvalidArgumentException($invalidCommand)
{ {
$mockBuilder = $this->getMockBuilder('Monolog\Handler\ProcessHandler');
$mockBuilder->disableOriginalConstructor();
$handler = $mockBuilder->getMock();
$this->setExpectedException('\InvalidArgumentException'); $this->setExpectedException('\InvalidArgumentException');
/** @var ProcessHandler $handler */ new ProcessHandler($invalidCommand, Logger::DEBUG);
$handler->__construct($invalidCommand);
} }
/** /**
@@ -108,13 +102,8 @@ class ProcessHandlerTest extends TestCase
*/ */
public function testConstructWithInvalidCwdThrowsInvalidArgumentException($invalidCwd) public function testConstructWithInvalidCwdThrowsInvalidArgumentException($invalidCwd)
{ {
$mockBuilder = $this->getMockBuilder('Monolog\Handler\ProcessHandler');
$mockBuilder->disableOriginalConstructor();
$handler = $mockBuilder->getMock();
$this->setExpectedException('\InvalidArgumentException'); $this->setExpectedException('\InvalidArgumentException');
/** @var ProcessHandler $handler */ new ProcessHandler(self::DUMMY_COMMAND, Logger::DEBUG, true, $invalidCwd);
$handler->__construct('fake command', Logger::DEBUG, true, $invalidCwd);
} }
/** /**
@@ -123,7 +112,7 @@ class ProcessHandlerTest extends TestCase
*/ */
public function testConstructWithValidCwdWorks() public function testConstructWithValidCwdWorks()
{ {
$handler = new ProcessHandler('echo', Logger::DEBUG, true, sys_get_temp_dir()); $handler = new ProcessHandler(self::DUMMY_COMMAND, Logger::DEBUG, true, sys_get_temp_dir());
$this->assertInstanceOf( $this->assertInstanceOf(
'Monolog\Handler\ProcessHandler', 'Monolog\Handler\ProcessHandler',
$handler, $handler,