1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Copyright (c) 2011-present Mediasift Ltd |
5
|
|
|
* All rights reserved. |
6
|
|
|
* |
7
|
|
|
* Redistribution and use in source and binary forms, with or without |
8
|
|
|
* modification, are permitted provided that the following conditions |
9
|
|
|
* are met: |
10
|
|
|
* |
11
|
|
|
* * Redistributions of source code must retain the above copyright |
12
|
|
|
* notice, this list of conditions and the following disclaimer. |
13
|
|
|
* |
14
|
|
|
* * Redistributions in binary form must reproduce the above copyright |
15
|
|
|
* notice, this list of conditions and the following disclaimer in |
16
|
|
|
* the documentation and/or other materials provided with the |
17
|
|
|
* distribution. |
18
|
|
|
* |
19
|
|
|
* * Neither the names of the copyright holders nor the names of his |
20
|
|
|
* contributors may be used to endorse or promote products derived |
21
|
|
|
* from this software without specific prior written permission. |
22
|
|
|
* |
23
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
24
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
25
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
26
|
|
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
27
|
|
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
28
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
29
|
|
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
30
|
|
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
31
|
|
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
32
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
33
|
|
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
34
|
|
|
* POSSIBILITY OF SUCH DAMAGE. |
35
|
|
|
* |
36
|
|
|
* @category Libraries |
37
|
|
|
* @package Storyplayer/Phases |
38
|
|
|
* @author Stuart Herbert <[email protected]> |
39
|
|
|
* @copyright 2011-present Mediasift Ltd www.datasift.com |
40
|
|
|
* @license http://www.opensource.org/licenses/bsd-license.php BSD License |
41
|
|
|
* @link http://datasift.github.io/storyplayer |
42
|
|
|
*/ |
43
|
|
|
|
44
|
|
|
namespace DataSift\Storyplayer\Phases; |
45
|
|
|
|
46
|
|
|
use Exception; |
47
|
|
|
use Storyplayer\SPv2\Modules\Exceptions\ActionFailedException; |
48
|
|
|
use Storyplayer\SPv2\Modules\Exceptions\ExpectFailedException; |
49
|
|
|
use Storyplayer\SPv2\Modules\Exceptions\NotImplementedException; |
50
|
|
|
use Storyplayer\SPv2\Modules\Exceptions\StoryShouldFailException; |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* the PreTestPrediction phase |
54
|
|
|
* |
55
|
|
|
* @category Libraries |
56
|
|
|
* @package Storyplayer/Phases |
57
|
|
|
* @author Stuart Herbert <[email protected]> |
58
|
|
|
* @copyright 2011-present Mediasift Ltd www.datasift.com |
59
|
|
|
* @license http://www.opensource.org/licenses/bsd-license.php BSD License |
60
|
|
|
* @link http://datasift.github.io/storyplayer |
61
|
|
|
*/ |
62
|
|
|
|
63
|
|
|
class PreTestPredictionPhase extends StoryPhase |
64
|
|
|
{ |
65
|
|
|
protected $sequenceNo = 3; |
66
|
|
|
|
67
|
|
|
public function doPhase($story) |
68
|
|
|
{ |
69
|
|
|
// shorthand |
70
|
|
|
$st = $this->st; |
71
|
|
|
$storyResult = $story->getResult(); |
72
|
|
|
|
73
|
|
|
// our return value |
74
|
|
|
$phaseResult = $this->getNewPhaseResult(); |
75
|
|
|
|
76
|
|
|
try { |
77
|
|
|
// do we have anything to do? |
78
|
|
|
if (!$story->hasPreTestPrediction()) |
79
|
|
|
{ |
80
|
|
|
$phaseResult->setContinuePlaying( |
81
|
|
|
$phaseResult::HASNOACTIONS, |
82
|
|
|
"story has no pre-test prediction instructions; skipping" |
83
|
|
|
); |
84
|
|
|
return $phaseResult; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
// setup the phase |
88
|
|
|
$this->doPerPhaseSetup(); |
89
|
|
|
|
90
|
|
|
// make the call |
91
|
|
|
$callbacks = $story->getPreTestPrediction(); |
92
|
|
|
|
93
|
|
|
foreach ($callbacks as $callback) { |
94
|
|
|
if (is_callable($callback)) { |
95
|
|
|
call_user_func($callback, $st); |
96
|
|
|
} |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
// if we get here, the PreTestPrediction worked with |
100
|
|
|
// no problems at all |
101
|
|
|
$phaseResult->setContinuePlaying(); |
102
|
|
|
} |
103
|
|
|
// in any of the expects() calls in the preflight checks fails, |
104
|
|
|
// an ActionFailedException will be thrown |
105
|
|
|
catch (ActionFailedException $e) { |
|
|
|
|
106
|
|
|
$phaseResult->setContinuePlaying( |
107
|
|
|
$phaseResult::FAILED, |
108
|
|
|
$e->getMessage(), |
109
|
|
|
$e |
110
|
|
|
); |
111
|
|
|
$storyResult->setStoryShouldFail(); |
112
|
|
|
} |
113
|
|
|
catch (ExpectFailedException $e) { |
|
|
|
|
114
|
|
|
$phaseResult->setContinuePlaying( |
115
|
|
|
$phaseResult::FAILED, |
116
|
|
|
$e->getMessage(), |
117
|
|
|
$e |
118
|
|
|
); |
119
|
|
|
$storyResult->setStoryShouldFail(); |
120
|
|
|
} |
121
|
|
|
// users can throw this to tell us that the story should fail |
122
|
|
|
catch (StoryShouldFailException $e) { |
|
|
|
|
123
|
|
|
$phaseResult->setContinuePlaying( |
124
|
|
|
$phaseResult::FAILED, |
125
|
|
|
$e->getMessage(), |
126
|
|
|
$e |
127
|
|
|
); |
128
|
|
|
$storyResult->setStoryShouldFail(); |
129
|
|
|
} |
130
|
|
|
// if any of the tests are incomplete, deal with that too |
131
|
|
|
catch (NotImplementedException $e) { |
|
|
|
|
132
|
|
|
$phaseResult->setPlayingFailed( |
133
|
|
|
$phaseResult::INCOMPLETE, |
134
|
|
|
$e->getMessage(), |
135
|
|
|
$e |
136
|
|
|
); |
137
|
|
|
$storyResult->setStoryIsIncomplete($phaseResult); |
138
|
|
|
} |
139
|
|
|
// deal with the things that go wrong |
140
|
|
|
catch (Exception $e) { |
141
|
|
|
$phaseResult->setPlayingFailed( |
142
|
|
|
$phaseResult::ERROR, |
143
|
|
|
$e->getMessage(), |
144
|
|
|
$e |
145
|
|
|
); |
146
|
|
|
$storyResult->setStoryHasError($phaseResult); |
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
// close off any open log actions |
150
|
|
|
$st->closeAllOpenActions(); |
151
|
|
|
|
152
|
|
|
// tidy up after ourselves |
153
|
|
|
$this->doPerPhaseTeardown(); |
154
|
|
|
|
155
|
|
|
// all done |
156
|
|
|
return $phaseResult; |
157
|
|
|
} |
158
|
|
|
} |
159
|
|
|
|
Scrutinizer analyzes your
composer.json
/composer.lock
file if available to determine the classes, and functions that are defined by your dependencies.It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.