|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of UnivNantes. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Monofony |
|
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
|
|
|
namespace App\Behat\Context\Cli; |
|
13
|
|
|
|
|
14
|
|
|
use App\Command\Installer\SetupCommand; |
|
15
|
|
|
use Symfony\Bundle\FrameworkBundle\Console\Application; |
|
16
|
|
|
use Symfony\Component\Console\Tester\CommandTester; |
|
17
|
|
|
|
|
18
|
|
|
class InstallerContext extends DefaultContext |
|
19
|
|
|
{ |
|
20
|
|
|
/** |
|
21
|
|
|
* @var array |
|
22
|
|
|
*/ |
|
23
|
|
|
private $inputChoices = [ |
|
24
|
|
|
'e-mail' => '[email protected]', |
|
25
|
|
|
'password' => 'pswd', |
|
26
|
|
|
'confirmation' => 'pswd', |
|
27
|
|
|
]; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* @Given I do not provide an email |
|
31
|
|
|
*/ |
|
32
|
|
|
public function iDoNotProvideEmail() |
|
33
|
|
|
{ |
|
34
|
|
|
$this->inputChoices['e-mail'] = ''; |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* @Given I do not provide a correct email |
|
39
|
|
|
*/ |
|
40
|
|
|
public function iDoNotProvideCorrectEmail() |
|
41
|
|
|
{ |
|
42
|
|
|
$this->inputChoices['e-mail'] = 'janusz'; |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* @Given I provide full administrator data |
|
47
|
|
|
*/ |
|
48
|
|
|
public function iProvideFullAdministratorData() |
|
49
|
|
|
{ |
|
50
|
|
|
$this->inputChoices['e-mail'] = '[email protected]'; |
|
51
|
|
|
$this->inputChoices['password'] = 'pswd1$'; |
|
52
|
|
|
$this->inputChoices['confirmation'] = $this->inputChoices['password']; |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* @param string $name |
|
57
|
|
|
*/ |
|
58
|
|
|
private function iExecuteCommandWithInputChoices($name) |
|
59
|
|
|
{ |
|
60
|
|
|
$this->questionHelper = $this->command->getHelper('question'); |
|
61
|
|
|
$this->getTester()->setInputs($this->inputChoices); |
|
62
|
|
|
|
|
63
|
|
|
try { |
|
64
|
|
|
$this->getTester()->execute(['command' => $name]); |
|
65
|
|
|
} catch (\Exception $e) { |
|
66
|
|
|
} |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* @When /^I run Install setup command$/ |
|
71
|
|
|
*/ |
|
72
|
|
|
public function iRunInstallSetupCommmandLine() |
|
73
|
|
|
{ |
|
74
|
|
|
$this->application = new Application($this->kernel); |
|
75
|
|
|
$this->application->add(new SetupCommand()); |
|
76
|
|
|
|
|
77
|
|
|
$this->command = $this->application->find('app:install:setup'); |
|
78
|
|
|
$this->setTester(new CommandTester($this->command)); |
|
79
|
|
|
|
|
80
|
|
|
$this->iExecuteCommandWithInputChoices('app:install:setup'); |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* @param string $name |
|
85
|
|
|
*/ |
|
86
|
|
|
protected function iExecuteCommandAndConfirm($name) |
|
87
|
|
|
{ |
|
88
|
|
|
$this->questionHelper = $this->command->getHelper('question'); |
|
89
|
|
|
|
|
90
|
|
|
$this->getTester()->setInputs(['y', 'y']); |
|
91
|
|
|
|
|
92
|
|
|
try { |
|
93
|
|
|
$this->getTester()->execute(['command' => $name]); |
|
94
|
|
|
} catch (\Exception $e) { |
|
95
|
|
|
} |
|
96
|
|
|
} |
|
97
|
|
|
} |
|
98
|
|
|
|