1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Test\PHPUnitGenerator\Example\AbstractClass; |
4
|
|
|
|
5
|
|
|
use PHPUnit\Framework\TestCase; |
6
|
|
|
use PHPUnitGenerator\Example\AbstractClass; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* Class AbstractClassTest |
10
|
|
|
* |
11
|
|
|
* @covers \PHPUnitGenerator\Example\AbstractClass |
12
|
|
|
*/ |
13
|
|
|
class AbstractClassTest extends TestCase |
14
|
|
|
{ |
15
|
|
|
/** |
16
|
|
|
* The trait/abstract class instance to test |
17
|
|
|
* @var AbstractClass $instance |
18
|
|
|
*/ |
19
|
|
|
protected $instance; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* Build the instance of AbstractClass |
23
|
|
|
*/ |
24
|
|
|
protected function setUp() |
25
|
|
|
{ |
26
|
|
|
$this->instance = $this->getMockBuilder(AbstractClass::class) |
27
|
|
|
->setConstructorArgs(['A simple string', $this->createMock(\PHPUnitGenerator\Example\BaseClass::class), $this->createMock(\ReflectionClass::class), $this->createMock(\DateTime::class), $this->createMock(\HttpRequest::class)]) |
28
|
|
|
->getMockForAbstractClass(); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @covers \PHPUnitGenerator\Example\AbstractClass::__construct() |
33
|
|
|
*/ |
34
|
|
|
public function testConstruct() |
35
|
|
|
{ |
36
|
|
|
// @todo: Complete this test |
37
|
|
|
$this->markTestIncomplete(); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @covers \PHPUnitGenerator\Example\AbstractClass::simpleAddition() |
42
|
|
|
*/ |
43
|
|
|
public function testSimpleAddition() |
44
|
|
|
{ |
45
|
|
|
$this->assertEquals(5, AbstractClass::simpleAddition(2, 3)); |
46
|
|
|
$this->assertEquals(0, AbstractClass::simpleAddition()); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @covers \PHPUnitGenerator\Example\AbstractClass::setProperty1() |
51
|
|
|
*/ |
52
|
|
|
public function testSetProperty1() |
53
|
|
|
{ |
54
|
|
|
$expected = true; |
55
|
|
|
|
56
|
|
|
$property = (new \ReflectionClass(AbstractClass::class))->getProperty('property1'); |
57
|
|
|
$property->setAccessible(true); |
58
|
|
|
|
59
|
|
|
$this->instance->setProperty1($expected); |
60
|
|
|
|
61
|
|
|
$this->assertEquals($expected, $property->getValue($this->instance)); |
62
|
|
|
} |
63
|
|
|
} |
64
|
|
|
|