1
votes

There is a particular PhpUnit test I am trying to run in PhpStorm that is behaving strangely. Please see the class below.

<?php

include_once('../ecoi/app/config.inc');

class formDataTest extends PHPUnit_Framework_TestCase {

public function testStateChange() {

$a = formData::calcCoiState(1);
$this - > assertEquals(1, $a);
   }
}

The bottom left viewer spits out a "Test Framework quit unexpectedly" error but the console output directly to the right has a "OK (1 test, 1 assertion) ..." message which I've come to interpret as a success. Now this is where it gets weird(er).

Modifying the "assertEquals" arguments from "1" to "2" will effectively fail the test and both the left and right panes function as expected. It's clearly logged as a successful failure, so to speak.

I have a "MoneyTest" class that will pass and fail gracefully (to rule out that there's a blanket bug with the "passing" of a test.

include_once('selenium/Money.php');

class MoneyTest extends PHPUnit_Framework_TestCase {
// ...

    public function testCanBeNegated()
    {
        // Arrange
        $a = new Money(1);

        // Act
        $b = $a->negate();

        // Assert
        $this->assertEquals(1, $b->getAmount());
    }

    // ...
}

The issue seems to have something to do with the class it's trying to reference. I'm just not sure why the fail registers appropriately, but the pass is only partially registered. Any advice would help, and I'd be happy to provide additional info.

1
1) Please check your php error log for possible details -- such message usually means that there were errors during execution (e.g. class was not loaded etc). 2) Do you use any PHPUnit customisations (like, custom printer etc)? Try not using them.LazyOne
I don't use any customizations. My PHPUnit is pointing right at the PHAR downloaded from the main PHPUnit site, without making any changes to it.daniel9x

1 Answers

1
votes

This seems to be an underlying issue with this test and phpStorm's particular interpretation of the current version of pHpUnit's response (4.3). I point my phpStorm instance to the 3.7 phpUnit Phar and it's functioning much more as expected.