Skip to content

Commit 6ee71dd

Browse files
committed
Add specs
1 parent e786dc3 commit 6ee71dd

File tree

3 files changed

+116
-1
lines changed

3 files changed

+116
-1
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Sylius package.
5+
*
6+
* (c) Sylius Sp. z o.o.
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
declare(strict_types=1);
13+
14+
namespace spec\Sylius\Component\Resource\StateMachine;
15+
16+
use App\Entity\PullRequest;
17+
use PhpSpec\ObjectBehavior;
18+
use Sylius\Component\Resource\StateMachine\StateMachine;
19+
use Sylius\Component\Resource\StateMachine\StateMachineInterface as LegacyStateMachineInterface;
20+
use Sylius\Resource\StateMachine\StateMachine as NewStateMachine;
21+
use Sylius\Resource\StateMachine\StateMachineInterface;
22+
23+
final class StateMachineSpec extends ObjectBehavior
24+
{
25+
function let(): void
26+
{
27+
$this->beConstructedWith(new PullRequest(), [
28+
'graph' => 'pull_request',
29+
'property_path' => 'currentPlace',
30+
'places' => [
31+
'start',
32+
'test',
33+
],
34+
'transitions' => [
35+
'submit' => [
36+
'from' => ['start'],
37+
'to' => 'test',
38+
],
39+
],
40+
]);
41+
}
42+
43+
function it_is_initializable(): void
44+
{
45+
$this->shouldHaveType(StateMachine::class);
46+
}
47+
48+
function it_implements_state_machine_interface(): void
49+
{
50+
$this->shouldImplement(StateMachineInterface::class);
51+
}
52+
53+
function it_implements_legacy_state_machine_interface(): void
54+
{
55+
$this->shouldImplement(LegacyStateMachineInterface::class);
56+
}
57+
58+
function it_should_be_an_alias_of_state_machine(): void
59+
{
60+
$this->shouldImplement(NewStateMachine::class);
61+
}
62+
}

src/Component/legacy/src/StateMachine/StateMachine.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,3 @@ final class StateMachine extends \Sylius\Resource\StateMachine\StateMachine
2020
{
2121
}
2222
}
23-
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Sylius package.
5+
*
6+
* (c) Sylius Sp. z o.o.
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
declare(strict_types=1);
13+
14+
namespace spec\Sylius\Resource\StateMachine;
15+
16+
use App\Entity\PullRequest;
17+
use PhpSpec\ObjectBehavior;
18+
use Sylius\Resource\StateMachine\StateMachine;
19+
20+
final class StateMachineSpec extends ObjectBehavior
21+
{
22+
function let(): void
23+
{
24+
$this->beConstructedWith(new PullRequest(), [
25+
'graph' => 'pull_request',
26+
'property_path' => 'currentPlace',
27+
'places' => [
28+
'start',
29+
'test',
30+
],
31+
'transitions' => [
32+
'submit' => [
33+
'from' => ['start'],
34+
'to' => 'test',
35+
],
36+
],
37+
]);
38+
}
39+
40+
function it_is_initializable(): void
41+
{
42+
$this->shouldHaveType(StateMachine::class);
43+
}
44+
45+
function it_gets_transition_from_a_state(): void
46+
{
47+
$this->getTransitionFromState('start')->shouldReturn('submit');
48+
}
49+
50+
function it_gets_transition_to_a_state(): void
51+
{
52+
$this->getTransitionToState('test')->shouldReturn('submit');
53+
}
54+
}

0 commit comments

Comments
 (0)