Passed
Push — master ( 069efd...bb88de )
by Dmitry
02:27
created

Tester::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
c 0
b 0
f 0
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace PHPKitchen\CodeSpecs\Specification;
4
5
use PHPKitchen\CodeSpecs\Contract\TestGuy;
6
use PHPKitchen\CodeSpecs\Mixin\TestGuyMethods;
7
use PHPUnit\Framework\Test;
8
9
/**
10
 * Tester is a simple class designed to make PHPUnit tests more readable using BDD-style
11
 * syntax. Tester represents a test-guy who is testing your code, so tests writes as a story
12
 * of what tester is doing. Example:
13
 * <pre>
14
 * // do stuff
15
 * .......
16
 * $I = $this->tester;
17
 * $I->describe('how user activates processor for PDF transformation to HTML');
18
 * $I->expectsThat('processor converts PDF to HTML and return HTML representation of given PDF.');
19
 * $I->seeString($processedContent)
20
 *      ->isEqualTo(self::EXPECTED_CONTENT);
21
 * </pre>
22
 *
23
 * @package PHPKitchen\CodeSpecs
24
 * @author Dmitry Kolodko <[email protected]>
25
 */
26
class Tester implements TestGuy {
27
    use TestGuyMethods;
28
29
    /**
30
     * Specifies what test guy expects from a set of matchers that would be defined next in the
31
     * specification.
32
     *
33
     * @param string $expectation expectation text.
34
     * Expectation should be a logical ending of "I expect to ". For example: "see user in the DB".
35
     * Such scenario would result in "I expect to see user in the DB" output in console.
36
     * @return $this
37
     */
38
    public function expectTo(string $expectation): TestGuy {
39
        $this->steps->add('I expect to ' . $expectation);
40
        return $this;
41
    }
42
43
    public function __construct(Test $test) {
44
        $this->context = $test;
45
        $this->initStepsList();
46
    }
47
}