Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Jul 1, 2024
1 parent cdc5842 commit b84e35d
Show file tree
Hide file tree
Showing 3 changed files with 292 additions and 0 deletions.
70 changes: 70 additions & 0 deletions tests/end-to-end/testdox/_files/OutcomeAndIssuesTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
* (c) Sebastian Bergmann <sebastian@phpunit.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PHPUnit\TestFixture\TestDox;

use const E_USER_DEPRECATED;
use const E_USER_NOTICE;
use const E_USER_WARNING;
use function trigger_error;
use Exception;
use PHPUnit\Framework\TestCase;

final class OutcomeAndIssuesTest extends TestCase
{
public function testSuccess(): void
{
$this->assertTrue(true);
}

public function testSuccessButRisky(): void
{
}

public function testSuccessButDeprecation(): void
{
$this->assertTrue(true);

trigger_error('message', E_USER_DEPRECATED);
}

public function testSuccessButNotice(): void
{
$this->assertTrue(true);

trigger_error('message', E_USER_NOTICE);
}

public function testSuccessButWarning(): void
{
$this->assertTrue(true);

trigger_error('message', E_USER_WARNING);
}

public function testFailure(): void
{
$this->assertTrue(false);
}

public function testError(): void
{
throw new Exception('message');
}

public function testIncomplete(): void
{
$this->markTestIncomplete('message');
}

public function testSkipped(): void
{
$this->markTestSkipped('message');
}
}
125 changes: 125 additions & 0 deletions tests/end-to-end/testdox/outcome-and-issues-with-summary.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
--TEST--
Different outcomes and issues (with TestDox summary)
--FILE--
<?php declare(strict_types=1);
$_SERVER['argv'][] = '--do-not-cache-result';
$_SERVER['argv'][] = '--no-configuration';
$_SERVER['argv'][] = '--colors=never';
$_SERVER['argv'][] = '--no-progress';
$_SERVER['argv'][] = '--display-incomplete';
$_SERVER['argv'][] = '--display-skipped';
$_SERVER['argv'][] = '--display-deprecations';
$_SERVER['argv'][] = '--display-notices';
$_SERVER['argv'][] = '--display-warnings';
$_SERVER['argv'][] = '--testdox';
$_SERVER['argv'][] = '--testdox-summary';
$_SERVER['argv'][] = __DIR__ . '/_files/OutcomeAndIssuesTest.php';

require_once __DIR__ . '/../../bootstrap.php';

(new PHPUnit\TextUI\Application)->run($_SERVER['argv']);
--EXPECTF--
PHPUnit %s by Sebastian Bergmann and contributors.

Runtime: %s

Time: %s, Memory: %s

Outcome And Issues (PHPUnit\TestFixture\TestDox\OutcomeAndIssues)
Success
Success but risky
Success but deprecation
Success but notice
Success but warning
Failure
Failed asserting that false is true.
│ %sOutcomeAndIssuesTest.php:53
Error
Exception: message
│ %sOutcomeAndIssuesTest.php:58
Incomplete
│ message
│ %sOutcomeAndIssuesTest.php:63
Skipped

Summary of tests with errors, failures, or issues:

Outcome And Issues (PHPUnit\TestFixture\TestDox\OutcomeAndIssues)
Success but risky
Success but deprecation
Success but notice
Success but warning
Failure
Failed asserting that false is true.
│ %sOutcomeAndIssuesTest.php:53
Error
Exception: message
│ %sOutcomeAndIssuesTest.php:58
Incomplete
│ message
│ %sOutcomeAndIssuesTest.php:63
Skipped

There was 1 risky test:

1) PHPUnit\TestFixture\TestDox\OutcomeAndIssuesTest::testSuccessButRisky
This test did not perform any assertions

%sOutcomeAndIssuesTest.php:26

--

1 test triggered 1 warning:

1) %sOutcomeAndIssuesTest.php:48
message

Triggered by:

* PHPUnit\TestFixture\TestDox\OutcomeAndIssuesTest::testSuccessButWarning
%sOutcomeAndIssuesTest.php:44

--

1 test triggered 1 notice:

1) %sOutcomeAndIssuesTest.php:41
message

Triggered by:

* PHPUnit\TestFixture\TestDox\OutcomeAndIssuesTest::testSuccessButNotice
%sOutcomeAndIssuesTest.php:37

--

1 test triggered 1 deprecation:

1) %sOutcomeAndIssuesTest.php:34
message

Triggered by:

* PHPUnit\TestFixture\TestDox\OutcomeAndIssuesTest::testSuccessButDeprecation
%sOutcomeAndIssuesTest.php:30

ERRORS!
Tests: 9, Assertions: 5, Errors: 1, Failures: 1, Warnings: 1, Deprecations: 1, Notices: 1, Skipped: 1, Incomplete: 1, Risky: 1.
97 changes: 97 additions & 0 deletions tests/end-to-end/testdox/outcome-and-issues-without-summary.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
--TEST--
Different outcomes and issues (without TestDox summary)
--FILE--
<?php declare(strict_types=1);
$_SERVER['argv'][] = '--do-not-cache-result';
$_SERVER['argv'][] = '--no-configuration';
$_SERVER['argv'][] = '--colors=never';
$_SERVER['argv'][] = '--no-progress';
$_SERVER['argv'][] = '--display-incomplete';
$_SERVER['argv'][] = '--display-skipped';
$_SERVER['argv'][] = '--display-deprecations';
$_SERVER['argv'][] = '--display-notices';
$_SERVER['argv'][] = '--display-warnings';
$_SERVER['argv'][] = '--testdox';
$_SERVER['argv'][] = __DIR__ . '/_files/OutcomeAndIssuesTest.php';

require_once __DIR__ . '/../../bootstrap.php';

(new PHPUnit\TextUI\Application)->run($_SERVER['argv']);
--EXPECTF--
PHPUnit %s by Sebastian Bergmann and contributors.

Runtime: %s

Time: %s, Memory: %s

Outcome And Issues (PHPUnit\TestFixture\TestDox\OutcomeAndIssues)
Success
Success but risky
Success but deprecation
Success but notice
Success but warning
Failure
Failed asserting that false is true.
│ %sOutcomeAndIssuesTest.php:53
Error
Exception: message
│ %sOutcomeAndIssuesTest.php:58
Incomplete
│ message
│ %sOutcomeAndIssuesTest.php:63
Skipped

There was 1 risky test:

1) PHPUnit\TestFixture\TestDox\OutcomeAndIssuesTest::testSuccessButRisky
This test did not perform any assertions

%sOutcomeAndIssuesTest.php:26

--

1 test triggered 1 warning:

1) %sOutcomeAndIssuesTest.php:48
message

Triggered by:

* PHPUnit\TestFixture\TestDox\OutcomeAndIssuesTest::testSuccessButWarning
%sOutcomeAndIssuesTest.php:44

--

1 test triggered 1 notice:

1) %sOutcomeAndIssuesTest.php:41
message

Triggered by:

* PHPUnit\TestFixture\TestDox\OutcomeAndIssuesTest::testSuccessButNotice
%sOutcomeAndIssuesTest.php:37

--

1 test triggered 1 deprecation:

1) %sOutcomeAndIssuesTest.php:34
message

Triggered by:

* PHPUnit\TestFixture\TestDox\OutcomeAndIssuesTest::testSuccessButDeprecation
%sOutcomeAndIssuesTest.php:30

ERRORS!
Tests: 9, Assertions: 5, Errors: 1, Failures: 1, Warnings: 1, Deprecations: 1, Notices: 1, Skipped: 1, Incomplete: 1, Risky: 1.

0 comments on commit b84e35d

Please sign in to comment.