Completed
Push — ui-tests-structure ( 9a3cd3...c02912 )
by Phil
36:00 queued 10:59
created

TextEditorContext::createATextFile()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

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 3
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 enter :text in the text file
57
	 */
58
	public function iEnterTextInTheTextFile($text)
59
	{
60
		$this->textEditorPage->typeIntoTextFile($text);
61
	}
62
63
	/**
64
	 * general before scenario for all text editor tests.
65
	 * This will run before EVERY scenario.
66
	 * It will set the properties for this object.
67
	 *
68
	 * @param BeforeScenarioScope $scope
69
	 * @return void
70
	 * @BeforeScenario
71
	 */
72
	public function before(BeforeScenarioScope $scope) {
73
		// Get the environment
74
		$environment = $scope->getEnvironment();
75
		// Get all the contexts you need in this context
76
		$this->featureContext = $environment->getContext('FeatureContext');
77
		$this->filesContext = $environment->getContext('FilesContext');
78
		$this->tmpDir = $this->getMinkParameter("show_tmp_dir");
79
		$suiteParameters = $scope->getEnvironment()->getSuite()
80
			->getSettings() ['context'] ['parameters'];
81
		$this->ocPath = $suiteParameters['ocPath'];
82
	}
83
}
84