\PHPUnit_Framework_TestCase

A TestCase defines the fixture to run multiple tests.

To define a TestCase

1) Implement a subclass of PHPUnit_Framework_TestCase.
2) Define instance variables that store the state of the fixture.
3) Initialize the fixture state by overriding setUp().
4) Clean-up after a test by overriding tearDown().

Each test runs in its own fixture so there can be no side effects
among test runs.

Here is an example:

<code>
<?php
class MathTest extends PHPUnit_Framework_TestCase
{
public $value1;
public $value2;

protected function setUp()
{
$this->value1 = 2;
$this->value2 = 3;
}
}
?>
</code>

For each test implement a method which interacts with the fixture.
Verify the expected results with assertions specified by calling
assert with a boolean.

<code>
<?php
public function testPass()
{
$this->assertTrue($this->value1 + $this->value2 == 5);
}
?>
</code>

Synopsis

class PHPUnit_Framework_TestCase extends PHPUnit_Framework_Assert implements PHPUnit_Framework_Test,PHPUnit_Framework_SelfDescribing {
}

Hierarchy

Violations

PHPMessDetector

Line Rule Message
605 - 718 CyclomaticComplexity The method run() has a Cyclomatic Complexity of 20. The configured cyclomatic complexity threshold is 10.
605 - 718 NPathComplexity The method run() has an NPath complexity of 1800192. The configured NPath complexity threshold is 200.
605 - 718 ExcessiveMethodLength The method run() has 114 lines of code. Current threshold is set to 100. Avoid really long methods.
723 - 872 CyclomaticComplexity The method runBare() has a Cyclomatic Complexity of 32. The configured cyclomatic complexity threshold is 10.
723 - 872 NPathComplexity The method runBare() has an NPath complexity of 460800. The configured NPath complexity threshold is 200.
723 - 872 ExcessiveMethodLength The method runBare() has 150 lines of code. Current threshold is set to 100. Avoid really long methods.
881 - 972 CyclomaticComplexity The method runTest() has a Cyclomatic Complexity of 15. The configured cyclomatic complexity threshold is 10.
881 - 972 NPathComplexity The method runTest() has an NPath complexity of 1072. The configured NPath complexity threshold is 200.
1378 - 1385 EvalExpression The method getMockFromWsdl() contains an eval expression.
1687 UnusedLocalVariable Avoid unused local variables such as '$key'.
1691 UnusedLocalVariable Avoid unused local variables such as '$iRecursiveCheck'.
1757 - 1816 CyclomaticComplexity The method handleDependencies() has a Cyclomatic Complexity of 10. The configured cyclomatic complexity threshold is 10.
1895 UnusedFormalParameter Avoid unused parameters such as '$template'.

Checkstyle

Line Column Severity Message
643 135 warning Line exceeds 120 characters; contains 134 characters
651 126 warning Line exceeds 120 characters; contains 125 characters
652 126 warning Line exceeds 120 characters; contains 125 characters
653 126 warning Line exceeds 120 characters; contains 125 characters
654 126 warning Line exceeds 120 characters; contains 125 characters
655 126 warning Line exceeds 120 characters; contains 125 characters
674 13 warning Line exceeds 120 characters; contains 122 characters
1232 19 error Space after opening parenthesis of function call prohibited
1232 19 error Expected 0 spaces before closing bracket; 1 found
1252 128 warning Line exceeds 120 characters; contains 127 characters
1253 148 warning Line exceeds 120 characters; contains 147 characters
1254 154 warning Line exceeds 120 characters; contains 153 characters
1255 164 warning Line exceeds 120 characters; contains 163 characters
1262 254 warning Line exceeds 120 characters; contains 253 characters
1308 233 warning Line exceeds 120 characters; contains 232 characters
1341 246 warning Line exceeds 120 characters; contains 245 characters
1371 181 warning Line exceeds 120 characters; contains 180 characters
1416 230 warning Line exceeds 120 characters; contains 229 characters
1448 210 warning Line exceeds 120 characters; contains 209 characters

Members

private

  • $data — array
  • $dataName — string
  • $dependencies — array
  • $dependencyInput — array
  • $expectedException — mixed
    The name of the expected Exception.
  • $expectedExceptionCode — integer
    The code of the expected Exception.
  • $expectedExceptionMessage — string
    The message of the expected Exception.
  • $expectedExceptionMessageRegExp — string
    The regex pattern to validate the expected Exception message.
  • $hasPerformedExpectationsOnOutputbool
  • $inIsolation — boolean
    Whether or not this test is running in a separate PHP process.
  • $iniSettings — array
  • $locale — array
  • $mockObjectGenerator — array
  • $mockObjects — array
  • $name — string
    The name of the test case.
  • $numAssertions — integer
  • $output — string
  • $outputBufferingActive — boolean
  • $outputBufferingLevel — integer
  • $outputCallback — mixed
  • $outputExpectedRegex — string
  • $outputExpectedString — string
  • $resultPHPUnit_Framework_TestResult
  • $status — integer
  • $statusMessage — string
  • $testResult — mixed
  • $useErrorHandler — boolean

protected

  • $backupGlobals — boolean
    Enable or disable the backup and restoration of the $GLOBALS array.
  • $backupGlobalsBlacklist — array
  • $backupStaticAttributes — boolean
    Enable or disable the backup and restoration of static attributes.
  • $backupStaticAttributesBlacklist — array
  • $preserveGlobalState — boolean
    Whether or not this test should preserve the global state when running in a separate PHP process.
  • $runTestInSeparateProcess — boolean
    Whether or not this test is to be run in a separate PHP process.

Methods

private

protected

public

Inherited from PHPUnit_Framework_Assert

public

History