|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of monofony. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Mobizel |
|
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 App\Behat\Context\Setup; |
|
15
|
|
|
|
|
16
|
|
|
use App\Behat\Service\SharedStorageInterface; |
|
17
|
|
|
use App\Entity\Article; |
|
18
|
|
|
use App\Fixture\Factory\ArticleExampleFactory; |
|
19
|
|
|
use Behat\Behat\Context\Context; |
|
20
|
|
|
use Sylius\Component\Resource\Repository\RepositoryInterface; |
|
21
|
|
|
|
|
22
|
|
|
final class ArticleContext implements Context |
|
23
|
|
|
{ |
|
24
|
|
|
/** @var SharedStorageInterface */ |
|
25
|
|
|
private $sharedStorage; |
|
26
|
|
|
|
|
27
|
|
|
/** @var ArticleExampleFactory */ |
|
28
|
|
|
private $articleFactory; |
|
29
|
|
|
|
|
30
|
|
|
/** @var RepositoryInterface */ |
|
31
|
|
|
private $articleRepository; |
|
32
|
|
|
|
|
33
|
|
|
public function __construct( |
|
34
|
|
|
SharedStorageInterface $sharedStorage, |
|
35
|
|
|
ArticleExampleFactory $articleFactory, |
|
36
|
|
|
RepositoryInterface $articleRepository |
|
37
|
|
|
) { |
|
38
|
|
|
$this->sharedStorage = $sharedStorage; |
|
39
|
|
|
$this->articleFactory = $articleFactory; |
|
40
|
|
|
$this->articleRepository = $articleRepository; |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* @Given there is (also )an article titled :title |
|
45
|
|
|
*/ |
|
46
|
|
|
public function thereIsAnAdministratorIdentifiedBy(string $title): void |
|
47
|
|
|
{ |
|
48
|
|
|
$this->createArticle(['title' => $title]); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* @param array $options |
|
53
|
|
|
*/ |
|
54
|
|
|
private function createArticle(array $options): void |
|
55
|
|
|
{ |
|
56
|
|
|
/** @var Article $article */ |
|
57
|
|
|
$article = $this->articleFactory->create($options); |
|
58
|
|
|
$this->articleRepository->add($article); |
|
59
|
|
|
$this->sharedStorage->set('article', $article); |
|
60
|
|
|
} |
|
61
|
|
|
} |
|
62
|
|
|
|