1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* \Wicked\Timely\FunctionalTest |
5
|
|
|
* |
6
|
|
|
* NOTICE OF LICENSE |
7
|
|
|
* |
8
|
|
|
* This source file is subject to the Open Software License (OSL 3.0) |
9
|
|
|
* that is available through the world-wide-web at this URL: |
10
|
|
|
* http://opensource.org/licenses/osl-3.0.php |
11
|
|
|
* |
12
|
|
|
* PHP version 5 |
13
|
|
|
* |
14
|
|
|
* @author Bernhard Wick <[email protected]> |
15
|
|
|
* @copyright 2016 Bernhard Wick |
16
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
17
|
|
|
* @link https://github.com/wick-ed/timely |
18
|
|
|
*/ |
19
|
|
|
|
20
|
|
|
namespace Wicked\Timely; |
21
|
|
|
|
22
|
|
|
use Wicked\Timely\Entities\TaskFactory; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* Functional tests |
26
|
|
|
* |
27
|
|
|
* @author Bernhard Wick <[email protected]> |
28
|
|
|
* @copyright 2016 Bernhard Wick |
29
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
30
|
|
|
* @link https://github.com/wick-ed/timely |
31
|
|
|
*/ |
32
|
|
|
class FunctionalTest extends \PHPUnit_Framework_TestCase |
33
|
|
|
{ |
34
|
|
|
|
35
|
|
|
public function fileStorageTaskGenerationProvider() |
36
|
|
|
{ |
37
|
|
|
return array( |
38
|
|
|
array('2016-07-26 18:38:16 | --ps-- | break; |
39
|
|
|
2016-07-26 17:57:36 | TEST-10 | work; |
40
|
|
|
2016-07-26 17:57:35 | --pe-- | ; |
41
|
|
|
2016-07-26 17:34:52 | --ps-- | break; |
42
|
|
|
2016-07-26 17:33:46 | TEST-9 | work; |
43
|
|
|
2016-07-26 15:18:38 | TEST-8 | work; |
44
|
|
|
2016-07-26 14:40:15 | --pe-- | ; |
45
|
|
|
2016-07-26 14:29:27 | --ps-- | break; |
46
|
|
|
2016-07-26 14:24:25 | TEST-7 | work; |
47
|
|
|
2016-07-26 12:32:38 | --pe-- | ; |
48
|
|
|
2016-07-26 12:09:41 | --ps-- | break; |
49
|
|
|
2016-07-26 12:05:25 | TEST-6 | work; |
50
|
|
|
2016-07-26 10:59:29 | TEST-5 | work; |
51
|
|
|
2016-07-26 10:12:26 | TEST-4 | work; |
52
|
|
|
2016-07-26 10:00:26 | TEST-3 | work; |
53
|
|
|
2016-07-26 09:55:58 | TEST-2 | work; |
54
|
|
|
2016-07-26 09:53:48 | --pe-- | ; |
55
|
|
|
2016-07-25 17:43:43 | --ps-- | break; |
56
|
|
|
2016-07-25 12:44:48 | TEST-1 | work;', |
57
|
|
|
10, |
58
|
|
|
array( |
59
|
|
|
'TEST-1' => 18065, // 4h 58m 55s + 2m 10s |
60
|
|
|
'TEST-2' => 268, // 4m 28s |
61
|
|
|
'TEST-3' => 720, // 12m |
62
|
|
|
'TEST-4' => 2823, // 47m 3s |
63
|
|
|
'TEST-5' => 3956, // 1h 5m 56s |
64
|
|
|
'TEST-6' => 6963, // 4m 16s + 1h 51m 47s |
65
|
|
|
'TEST-7' => 2605, // 5m 2s + 38m 23s |
66
|
|
|
'TEST-8' => 8108, // 2h 15m 8s |
67
|
|
|
'TEST-9' => 67, // 1m 6s + 1s |
68
|
|
|
'TEST-10' => 2440 // 40m 40s |
69
|
|
|
)), |
70
|
|
|
array('2016-07-26 13:41:49 | --ps-- | break; |
71
|
|
|
2016-07-26 10:38:17 | TEST-3 | work; |
72
|
|
|
2016-07-26 10:18:45 | TEST-2 | work; |
73
|
|
|
2016-07-26 08:37:56 | --pe-- | ; |
74
|
|
|
2016-07-25 18:48:48 | --ps-- | break; |
75
|
|
|
2016-07-25 16:13:53 | --pe-- | ; |
76
|
|
|
2016-07-25 16:00:58 | --ps-- | break; |
77
|
|
|
2016-07-25 14:20:57 | --pe-- | ; |
78
|
|
|
2016-07-25 13:42:35 | --ps-- | break; |
79
|
|
|
2016-07-25 10:18:04 | --pe-- | ; |
80
|
|
|
2016-07-23 18:10:08 | --ps-- | break; |
81
|
|
|
2016-07-23 13:00:02 | --pe-- | ; |
82
|
|
|
2016-07-23 12:30:24 | --ps-- | break; |
83
|
|
|
2016-07-23 10:29:55 | TEST-1 | work;', |
84
|
|
|
3, |
85
|
|
|
array( |
86
|
|
|
'TEST-1' => 59451, // 2h 29s + 5h 10m 6s + 3h 24m 31s + 1h 40m 1s + 2h 34m 55s + 1h 40m 49s |
87
|
|
|
'TEST-2' => 1172, // 19m 32s |
88
|
|
|
'TEST-3' => 11012 // 3h 3m 32s |
89
|
|
|
) |
90
|
|
|
) |
91
|
|
|
); |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* @dataProvider fileStorageTaskGenerationProvider |
96
|
|
|
*/ |
97
|
|
|
public function testFileStorageTaskGeneration($testContent, $taskCount, $expectedDurations) |
98
|
|
|
{ |
99
|
|
|
// get us a mocked file storage with our content |
100
|
|
|
$classToMock = '\Wicked\Timely\Storage\File'; |
101
|
|
|
/** @var \Wicked\Timely\Storage\File $mockFileStorage */ |
102
|
|
|
$mockFileStorage = $this->getMockBuilder($classToMock) |
103
|
|
|
->setMethods(array('getStorageContent')) |
104
|
|
|
->getMock(); |
105
|
|
|
$mockFileStorage->expects($this->once()) |
|
|
|
|
106
|
|
|
->method('getStorageContent') |
107
|
|
|
->will($this->returnValue($testContent)); |
108
|
|
|
|
109
|
|
|
// generate the tasks |
110
|
|
|
$bookings = $mockFileStorage->retrieve(); |
111
|
|
|
$tasks = TaskFactory::getTasksFromBookings($bookings); |
112
|
|
|
|
113
|
|
|
// first test: count the tasks |
114
|
|
|
$this->assertCount($taskCount, $tasks); |
115
|
|
|
|
116
|
|
|
// the expected tasks |
117
|
|
|
$expectedTicketIds = array_keys($expectedDurations); |
118
|
|
|
// iterate the tasks and check their ticketIds |
119
|
|
|
foreach ($tasks as $task) { |
120
|
|
|
$this->assertContains($task->getStartBooking()->getTicketId(), $expectedTicketIds); |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
// iterate the tasks and check their duration |
124
|
|
|
foreach ($tasks as $task) { |
125
|
|
|
$this->assertEquals($expectedDurations[$task->getStartBooking()->getTicketId()], $task->getDuration()); |
126
|
|
|
} |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
|
130
|
|
|
} |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.