Skip to content

Commit 754a7da

Browse files
committed
add suite_tests.php
1 parent 41fea0e commit 754a7da

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

tests/suite_tests.php

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?php
2+
3+
use \FUnit as fu;
4+
use \FUnit\TestSuite;
5+
6+
require_once __DIR__ . '/../src/FUnit.php';
7+
8+
fu::suite('Test suite tests');
9+
10+
fu::setup(function () {
11+
fu::fixture('ts', new TestSuite('Fixture Suite'));
12+
});
13+
14+
fu::teardown(function () {
15+
fu::reset_fixtures();
16+
});
17+
18+
fu::test("Check suite name", function () {
19+
$ts = fu::fixture('ts');
20+
fu::strict_equal('Fixture Suite', $ts->getName());
21+
});
22+
23+
fu::test("Check suite run state", function () {
24+
$ts = fu::fixture('ts');
25+
fu::strict_equal(false, $ts->run);
26+
$ts->run();
27+
fu::strict_equal(true, $ts->run);
28+
});
29+
30+
fu::test("Check suite exit code 1", function () {
31+
$ts = fu::fixture('ts');
32+
fu::strict_equal(0, $ts->getExitCode());
33+
$ts->addTest('known to fail for suite', function () use ($ts) {
34+
// this forces the result of this assertion to be recorded in
35+
// the `$ts` TestSuite instance
36+
fu::fail($ts, 'this always fails');
37+
});
38+
$ts->run();
39+
fu::strict_equal(1, $ts->getExitCode());
40+
});
41+
42+
fu::test("Check suite exit code 0", function () {
43+
$ts = fu::fixture('ts');
44+
fu::strict_equal(0, $ts->getExitCode());
45+
$ts->addTest('known to fail for suite', function () use ($ts) {
46+
// this forces the result of this assertion to be recorded in
47+
// the `$ts` TestSuite instance
48+
fu::pass($ts, 'this always fails');
49+
});
50+
$ts->run();
51+
fu::strict_equal(0, $ts->getExitCode());
52+
});
53+
54+
fu::run();

0 commit comments

Comments
 (0)