Completed
Push — ui-tests-structure ( c02912...b31cd9 )
by Phil
24:56
created

TextEditorContext::iEnterTextInTheTextFile()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
/**
3
* ownCloud
4
*
5
* @author Phillip Davis
6
* @copyright 2017 Phillip Davis [email protected]
7
*
8
* This library is free software; you can redistribute it and/or
9
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
10
* License as published by the Free Software Foundation; either
11
* version 3 of the License, or any later version.
12
*
13
* This library is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
17
*
18
* You should have received a copy of the GNU Affero General Public
19
* License along with this library.  If not, see <http://www.gnu.org/licenses/>.
20
*
21
*/
22
23
use Behat\Behat\Context\Context;
24
use Behat\Behat\Hook\Scope\BeforeScenarioScope;
25
use Behat\MinkExtension\Context\RawMinkContext;
26
use Page\TextEditorPage;
27
28
require_once 'bootstrap.php';
29
30
/**
31
 * Files context.
32
 */
33
class TextEditorContext extends RawMinkContext implements Context
34
{
35
	private $textEditorPage;
36
	private $featureContext;
37
	private $filesContext;
38
39
	public function __construct(TextEditorPage $textEditorPage)
40
	{
41
		$this->textEditorPage = $textEditorPage;
42
	}
43
44
	/**
45
	 * @When I create a text file with the name :name
46
	 *
47
	 * @param string $name
48
	 * @return void
49
	 */
50
	public function createATextFile($name) {
51
		$this->textEditorPage->createTextFile($name);
52
		$this->textEditorPage->waitTillEditorIsLoaded();
53
	}
54
55
	/**
56
	 * @When I input :text in the text area
57
	 */
58
	public function iInputTextInTheTextArea($text)
59
	{
60
		$this->textEditorPage->typeIntoTextFile($text);
61
	}
62
63
	/**
64
	 * @When I input the following text in the text area:
65
	 */
66
	public function iInputTheFollowingInTheTextArea(\Behat\Gherkin\Node\PyStringNode $multiLineText)
67
	{
68
		$this->textEditorPage->typeIntoTextFile($multiLineText->getRaw());
69
	}
70
71
	/**
72
	 * general before scenario for all text editor tests.
73
	 * This will run before EVERY scenario.
74
	 * It will set the properties for this object.
75
	 *
76
	 * @param BeforeScenarioScope $scope
77
	 * @return void
78
	 * @BeforeScenario
79
	 */
80
	public function before(BeforeScenarioScope $scope) {
81
		// Get the environment
82
		$environment = $scope->getEnvironment();
83
		// Get all the contexts you need in this context
84
		$this->featureContext = $environment->getContext('FeatureContext');
85
		$this->filesContext = $environment->getContext('FilesContext');
86
		$this->tmpDir = $this->getMinkParameter("show_tmp_dir");
87
		$suiteParameters = $scope->getEnvironment()->getSuite()
88
			->getSettings() ['context'] ['parameters'];
89
		$this->ocPath = $suiteParameters['ocPath'];
90
	}
91
}
92