Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Jan Kuchař
grifart-enum
Commits
71079e17
Commit
71079e17
authored
Jan 10, 2019
by
Jan Kuchař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed after rebase
parent
0c4bb6dd
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
11 deletions
+12
-11
tests/Example/OrderState/refactoring-1.phpt
tests/Example/OrderState/refactoring-1.phpt
+1
-1
tests/Example/OrderState/refactoring-4.phpt
tests/Example/OrderState/refactoring-4.phpt
+7
-6
tests/Example/OrderState/refactoring-5.phpt
tests/Example/OrderState/refactoring-5.phpt
+4
-4
No files found.
tests/Example/OrderState/refactoring-1.phpt
View file @
71079e17
...
...
@@ -102,7 +102,7 @@ Assert::false(
)
);
// check for
invalid
completely invalid arguments
// check for completely invalid arguments
Assert
::
exception
(
function
()
use
(
$orderService
)
{
$orderService
->
canDoTransition
(
'invalid'
,
'non-existing'
);
},
\
LogicException
::
class
);
...
...
tests/Example/OrderState/refactoring-4.phpt
View file @
71079e17
...
...
@@ -38,14 +38,15 @@ final class OrderState extends Enum
/**
* @param string[] $nextAllowedStates
*/
protected
function
__construct
(
array
$nextAllowedStates
)
protected
function
__construct
(
$scalar
,
array
$nextAllowedStates
)
{
parent
::
__construct
(
$scalar
);
$this
->
nextAllowedStates
=
$nextAllowedStates
;
}
public
function
canDoTransition
(
OrderState
$nextState
):
bool
{
return
\
in_array
(
$nextState
->
ge
tScalar
Value
(),
$this
->
nextAllowedStates
,
TRUE
);
return
\
in_array
(
$nextState
->
t
o
Scalar
(),
$this
->
nextAllowedStates
,
TRUE
);
}
...
...
@@ -57,10 +58,10 @@ final class OrderState extends Enum
// again and you will get infinite loop.
return
[
self
::
RECEIVED
=>
new
self
(
[
self
::
PROCESSING
,
self
::
CANCELLED
]),
self
::
PROCESSING
=>
new
self
(
[
self
::
FINISHED
]),
self
::
FINISHED
=>
new
self
(
[]),
self
::
CANCELLED
=>
new
self
(
[]),
new
self
(
self
::
RECEIVED
,
[
self
::
PROCESSING
,
self
::
CANCELLED
]),
new
self
(
self
::
PROCESSING
,
[
self
::
FINISHED
]),
new
self
(
self
::
FINISHED
,
[]),
new
self
(
self
::
CANCELLED
,
[]),
];
}
}
...
...
tests/Example/OrderState/refactoring-5.phpt
View file @
71079e17
...
...
@@ -79,7 +79,7 @@ abstract class OrderState extends Enum {
final
protected
static
function
provideInstances
():
array
{
return
[
self
::
RECEIVED
=>
new
class
extends
OrderState
{
new
class
(
self
::
RECEIVED
)
extends
OrderState
{
public
function
canDoTransition
(
OrderState
$nextState
):
bool
{
...
...
@@ -89,7 +89,7 @@ abstract class OrderState extends Enum {
},
self
::
PROCESSING
=>
new
class
extends
OrderState
{
new
class
(
self
::
PROCESSING
)
extends
OrderState
{
public
function
canDoTransition
(
OrderState
$nextState
):
bool
{
return
$nextState
===
$this
::
FINISHED
();
...
...
@@ -97,7 +97,7 @@ abstract class OrderState extends Enum {
},
self
::
FINISHED
=>
new
class
extends
OrderState
{
new
class
(
self
::
FINISHED
)
extends
OrderState
{
public
function
canDoTransition
(
OrderState
$nextState
):
bool
{
...
...
@@ -112,7 +112,7 @@ abstract class OrderState extends Enum {
},
self
::
CANCELLED
=>
new
class
extends
OrderState
{
new
class
(
self
::
CANCELLED
)
extends
OrderState
{
public
function
canDoTransition
(
OrderState
$nextState
):
bool
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment