Completed
Push — texteditor-ui-tests-01 ( 373aa3...e6f262 )
by Phil
21:02
created

iInputTheFollowingInTheTextArea()   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\Gherkin\Node\PyStringNode;
26
use Behat\MinkExtension\Context\RawMinkContext;
27
use Page\TextEditorPage;
28
29
require_once 'bootstrap.php';
30
31
/**
32
 * Files context.
33
 */
34
class TextEditorContext extends RawMinkContext implements Context
35
{
36
	private $textEditorPage;
37
	private $featureContext;
38
	private $filesContext;
39
40
	public function __construct(TextEditorPage $textEditorPage)
41
	{
42
		$this->textEditorPage = $textEditorPage;
43
	}
44
45
	/**
46
	 * @When /^I create a text file with the name ((?:'[^']*')|(?:"[^"]*"))( and the default file type|)$/
47
	 *
48
	 * @param string $name
49
	 * @return void
50
	 */
51
	public function createATextFileWithDefaultFileType($name, $and = '') {
52
		// The capturing group of the regex always includes the quotes at each
53
		// end of the captured string, so trim them.
54
		$name = trim($name, $name[0]);
55
		$this->textEditorPage->createTextFile($name, strlen($and) ? true : false);
56
		$this->textEditorPage->waitTillEditorIsLoaded();
57
	}
58
59
	/**
60
	 * @When I input :text in the text area
61
	 */
62
	public function iInputTextInTheTextArea($text)
63
	{
64
		$this->textEditorPage->typeIntoTextFile($text);
65
	}
66
67
	/**
68
	 * @When I input the following text in the text area:
69
	 */
70
	public function iInputTheFollowingInTheTextArea(PyStringNode $multiLineText)
71
	{
72
		$this->textEditorPage->typeIntoTextFile($multiLineText->getRaw());
73
	}
74
75
	/**
76
	 * @When I close the text editor
77
	 */
78
	public function iCloseTheTextEditor()
79
	{
80
		$this->textEditorPage->closeTheTextEditor();
81
	}
82
83
	/**
84
	 * general before scenario for all text editor tests.
85
	 * This will run before EVERY scenario.
86
	 * It will set the properties for this object.
87
	 *
88
	 * @param BeforeScenarioScope $scope
89
	 * @return void
90
	 * @BeforeScenario
91
	 */
92
	public function before(BeforeScenarioScope $scope) {
93
		// Get the environment
94
		$environment = $scope->getEnvironment();
95
		// Get all the contexts you need in this context
96
		$this->featureContext = $environment->getContext('FeatureContext');
97
		$this->filesContext = $environment->getContext('FilesContext');
98
		$this->tmpDir = $this->getMinkParameter("show_tmp_dir");
99
		$suiteParameters = $scope->getEnvironment()->getSuite()
100
			->getSettings() ['context'] ['parameters'];
101
		$this->ocPath = $suiteParameters['ocPath'];
102
	}
103
}
104