Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Commit

Permalink
Improving exception assertions.
Browse files Browse the repository at this point in the history
  • Loading branch information
nikolaposa committed Nov 23, 2015
1 parent 8aea829 commit 0f542de
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions test/Container/ApplicationFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1122,8 +1122,10 @@ public function testExceptionIsRaisedInCaseOfInvalidRouteMethodsConfiguration()
->get('config')
->willReturn($config);

$this->setExpectedException('Zend\Expressive\Container\Exception\InvalidArgumentException');

$this->setExpectedException(
'Zend\Expressive\Container\Exception\InvalidArgumentException',
'route must be in form of an array; received "string'
);
$this->factory->__invoke($this->container->reveal());
}

Expand Down Expand Up @@ -1177,8 +1179,10 @@ public function testExceptionIsRaisedInCaseOfInvalidRouteOptionsConfiguration()
->get('config')
->willReturn($config);

$this->setExpectedException('Zend\Expressive\Container\Exception\InvalidArgumentException');

$this->setExpectedException(
'Zend\Expressive\Container\Exception\InvalidArgumentException',
'options must be an array; received "string"'
);
$this->factory->__invoke($this->container->reveal());
}

Expand Down Expand Up @@ -1231,8 +1235,10 @@ public function testExceptionIsRaisedInCaseOfInvalidPreRoutingMiddlewarePipeline
->get('config')
->willReturn($config);

$this->setExpectedException('Zend\Expressive\Container\Exception\InvalidArgumentException');

$this->setExpectedException(
'Zend\Expressive\Container\Exception\InvalidArgumentException',
'middleware collection must be an array; received "string"'
);
$this->factory->__invoke($this->container->reveal());
}

Expand Down Expand Up @@ -1285,8 +1291,10 @@ public function testExceptionIsRaisedInCaseOfInvalidPostRoutingMiddlewarePipelin
->get('config')
->willReturn($config);

$this->setExpectedException('Zend\Expressive\Container\Exception\InvalidArgumentException');

$this->setExpectedException(
'Zend\Expressive\Container\Exception\InvalidArgumentException',
'middleware collection must be an array; received "string"'

This comment has been minimized.

Copy link
@Maks3w

Maks3w Nov 23, 2015

Member

Observe this is the same string as the used on testExceptionIsRaisedInCaseOfInvalidPreRoutingMiddlewarePipeline. How are you sure the exception is raised by post routing and not a false negative from pre routing?

This comment has been minimized.

Copy link
@Maks3w

Maks3w Nov 23, 2015

Member

For me the most important to be sure to catch the correct exception because a bug here affect to the execution of the progam.

A buggy detailed explanation (unuseful received "any") is less important.

This comment has been minimized.

This comment has been minimized.

Copy link
@Maks3w

Maks3w Nov 23, 2015

Member

There are a lot of personal styles in this things. But your boss will blame you if the program execution was not correct tested and allow him to put 1M$ in your salary :)

);
$this->factory->__invoke($this->container->reveal());
}
}

0 comments on commit 0f542de

Please sign in to comment.