Skip to content

Commit

Permalink
Cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Jul 7, 2010
1 parent 1caba1f commit 1390b35
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 104 deletions.
23 changes: 12 additions & 11 deletions PHPUnit/Framework/TestResult.php
Expand Up @@ -160,7 +160,7 @@ class PHPUnit_Framework_TestResult implements Countable
/**
* @var boolean
*/
protected $assertStrict = FALSE;
protected $strictAssertions = FALSE;

/**
* @var boolean
Expand Down Expand Up @@ -649,11 +649,13 @@ public function run(PHPUnit_Framework_Test $test)

$test->addToAssertionCount(PHPUnit_Framework_Assert::getCount());

if ($this->assertStrict && $test->getNumAssertions() == 0) {
if ($this->strictAssertions && $test->getNumAssertions() == 0) {
$this->addFailure(
$test,
new PHPUnit_Framework_IncompleteTestError('This test did not perform any assertions'),
$time
$test,
new PHPUnit_Framework_IncompleteTestError(
'This test did not perform any assertions'
),
$time
);
}

Expand Down Expand Up @@ -768,18 +770,17 @@ public function stopOnFailure($flag)
}

/**
* Enables tests to be marked as incomplete if no assertions are made in the
* unit tests
* Enables or disables the marking of a test as incomplete if no assertions
* are made.
*
* @param boolean $flag
* @throws InvalidArgumentException
*
* @return void
* @since Method available since Release 3.5.0
*/
public function assertStrict($flag)
public function strictAssertions($flag)
{
if (is_bool($flag)) {
$this->assertStrict = $flag;
$this->strictAssertions = $flag;
} else {
throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'boolean');
}
Expand Down
11 changes: 6 additions & 5 deletions PHPUnit/TextUI/Command.php
Expand Up @@ -106,6 +106,7 @@ class PHPUnit_TextUI_Command
'story' => NULL,
'story-html=' => NULL,
'story-text=' => NULL,
'strict' => NULL,
'syntax-check' => NULL,
'tap' => NULL,
'testdox' => NULL,
Expand All @@ -116,8 +117,7 @@ class PHPUnit_TextUI_Command
'static-backup' => NULL,
'verbose' => NULL,
'version' => NULL,
'wait' => NULL,
'assert-strict' => NULL
'wait' => NULL
);

/**
Expand Down Expand Up @@ -501,9 +501,10 @@ protected function handleArguments(array $argv)
}
break;

case '--assert-strict' : {
$this->arguments['assertStrict'] = TRUE;
case '--strict': {
$this->arguments['strict'] = TRUE;
}
break;

default: {
$optionName = str_replace('--', '', $option[0]);
Expand Down Expand Up @@ -812,9 +813,9 @@ protected function showHelp()
--stop-on-failure Stop execution upon first error or failure.
--stop-on-skipped Stop execution upon first skipped test.
--stop-on-incomplete Stop execution upon first incomplete test.
--strict Mark a test as incomplete if no assertions are made.
--verbose Output more verbose information.
--wait Waits for a keystroke after each test.
--assert-strict Mark test as incomplete if no assertions made.
--skeleton-class Generate Unit class for UnitTest in UnitTest.php.
--skeleton-test Generate UnitTest class for Unit in Unit.php.
Expand Down
4 changes: 2 additions & 2 deletions PHPUnit/TextUI/TestRunner.php
Expand Up @@ -292,8 +292,8 @@ public function doRun(PHPUnit_Framework_Test $suite, array $arguments = array())
);
}

if (isset($arguments['assertStrict'])) {
$result->assertStrict(TRUE);
if (isset($arguments['strict'])) {
$result->strictAssertions(TRUE);
}

$suite->run(
Expand Down
80 changes: 0 additions & 80 deletions Samples/BankAccount/BankAccountFailureTest.php

This file was deleted.

2 changes: 1 addition & 1 deletion Tests/TextUI/help.phpt
Expand Up @@ -45,9 +45,9 @@ Usage: phpunit [switches] UnitTest [UnitTest.php]
--stop-on-failure Stop execution upon first error or failure.
--stop-on-skipped Stop execution upon first skipped test.
--stop-on-incomplete Stop execution upon first incomplete test.
--strict Mark a test as incomplete if no assertions are made.
--verbose Output more verbose information.
--wait Waits for a keystroke after each test.
--assert-strict Mark test as incomplete if no assertions made.

--skeleton-class Generate Unit class for UnitTest in UnitTest.php.
--skeleton-test Generate UnitTest class for Unit in Unit.php.
Expand Down
2 changes: 1 addition & 1 deletion Tests/TextUI/help2.phpt
Expand Up @@ -46,9 +46,9 @@ Usage: phpunit [switches] UnitTest [UnitTest.php]
--stop-on-failure Stop execution upon first error or failure.
--stop-on-skipped Stop execution upon first skipped test.
--stop-on-incomplete Stop execution upon first incomplete test.
--strict Mark a test as incomplete if no assertions are made.
--verbose Output more verbose information.
--wait Waits for a keystroke after each test.
--assert-strict Mark test as incomplete if no assertions made.

--skeleton-class Generate Unit class for UnitTest in UnitTest.php.
--skeleton-test Generate UnitTest class for Unit in Unit.php.
Expand Down
8 changes: 4 additions & 4 deletions Tests/TextUI/assert-strict.phpt → Tests/TextUI/strict.phpt
@@ -1,11 +1,11 @@
--TEST--
phpunit --assert-strict BankAccountTest ../Samples/BankAccount/BankAccountFailureTest.php
phpunit --strict NothingTest ../_files/NothingTest.php
--FILE--
<?php
$_SERVER['argv'][1] = '--no-configuration';
$_SERVER['argv'][2] = '--assert-strict';
$_SERVER['argv'][4] = 'BankAccountTest';
$_SERVER['argv'][5] = dirname(__FILE__).'/../../Samples/BankAccount/BankAccountFailureTest.php';
$_SERVER['argv'][2] = '--strict';
$_SERVER['argv'][3] = 'NothingTest';
$_SERVER['argv'][4] = dirname(dirname(__FILE__)) . '/_files/NothingTest.php';

require_once dirname(dirname(dirname(__FILE__))) . '/PHPUnit/Autoload.php';
PHPUnit_TextUI_Command::main();
Expand Down
7 changes: 7 additions & 0 deletions Tests/_files/NothingTest.php
@@ -0,0 +1,7 @@
<?php
class NothingTest extends PHPUnit_Framework_TestCase
{
public function testNothing()
{
}
}

0 comments on commit 1390b35

Please sign in to comment.