Hotfix : Zend\Test trace error flag #6041

Closed
wants to merge 4 commits into
from

Conversation

Projects
None yet
2 participants
Contributor

blanchonvincent commented Mar 26, 2014

Current behavior is annoying because exception are automatically thrown ... currently, you can't assert application exception and debug your application

@@ -26,6 +26,8 @@ public function setUp()
include __DIR__ . '/../../_files/application.config.php'
);
parent::setUp();
+
+ $this->setTraceError(true);
@Ocramius

Ocramius Mar 26, 2014

Member

I'd suggest the opposite. This is an annoying breakage, and the feature should be opt-in.

@blanchonvincent

blanchonvincent Mar 26, 2014

Contributor

breakage? it's just a test

@Ocramius

Ocramius Mar 26, 2014

Member

Well, it will make any test based on (for example) testing unauthorized access break for consumer libraries. That's what I mean by "breakage"

@blanchonvincent

blanchonvincent Mar 26, 2014

Contributor

@Ocramius Ok I will change this, thank you Ocra

+ $exception = $this->getApplication()->getMvcEvent()->getParam('exception');
+ $this->assertInstanceOf('RuntimeException', $exception);
+
+ // set to null to avoid the throwing of the exception
@Ocramius

Ocramius Mar 26, 2014

Member

Use setExpectedException instead (to verify the throwing) or add a new test doing that (not sure if there is already one)

@blanchonvincent

blanchonvincent Mar 26, 2014

Contributor

I can't use setExpectedException, because throwing is done in the tearDown() now

@Ocramius

Ocramius Mar 26, 2014

Member

And tearDown is not catched by PHPUnit as test failure in case of exceptions?

@blanchonvincent

blanchonvincent Mar 26, 2014

Contributor

I don't know but I thought it's not a good practice, what do you think ?

@Ocramius

Ocramius Mar 26, 2014

Member

In theory, any failure, wherever it happens (setUp or tearDown) is a catchable error for PHPUnit...

@blanchonvincent

blanchonvincent Mar 26, 2014

Contributor

And I will need to add something like this :

public function tearDown()
{
    if($this->getName() == 'testThrowingException()') {
         $this->setExpectedException('');
         parent::tearDown();
    }
}

Not very clean ?

@Ocramius

Ocramius Mar 26, 2014

Member

So setExpectedException simply won't work in tearDown? if that's the case, then this is perfectly ok.

@blanchonvincent

blanchonvincent Mar 26, 2014

Contributor

No because, just one or 2 tests throw exception, not all tests

@Ocramius Ocramius added this to the 2.3.1 milestone Apr 2, 2014

@Ocramius Ocramius self-assigned this Apr 2, 2014

@Ocramius Ocramius closed this in 1158721 Apr 2, 2014

Ocramius added a commit that referenced this pull request Apr 2, 2014

gianarb pushed a commit to zendframework/zend-test that referenced this pull request May 15, 2015

gianarb pushed a commit to zendframework/zend-test that referenced this pull request May 15, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment