Completed
Push — master ( 0ea243...da58d4 )
by Henry
10:25 queued 33s
created

ConsoleTest::testTitle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.9
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
namespace Redaxscript\Tests;
3
4
use Facebook\WebDriver\WebDriverBy;
5
use Redaxscript\Console\Command;
6
7
/**
8
 * ConsoleTest
9
 *
10
 * @since 4.0.0
11
 *
12
 * @package Redaxscript
13
 * @category Tests
14
 * @author Henry Ruhs
15
 */
16
17
class ConsoleTest extends TestCaseAbstract
18
{
19
	/**
20
	 * setUp
21
	 *
22
	 * @since 4.0.0
23
	 */
24
25
	public function setUp() : void
26
	{
27
		parent::setUp();
28
		$this->_driver->get('http://localhost:8000/console.php');
29
	}
30
31
	/**
32
	 * testTitle
33
	 *
34
	 * @since 4.0.0
35
	 */
36
37
	public function testTitle() : void
38
	{
39
		/* expect and actual */
40
41
		$expect = $this->_language->get('console');
42
		$actual = $this->_driver->getTitle();
43
44
		/* compare */
45
46
		$this->assertEquals($expect, $actual);
47
	}
48
49
	/**
50
	 * testBehaviour
51
	 *
52
	 * @since 4.0.0
53
	 */
54
55
	public function testBehaviour() : void
56
	{
57
		/* setup */
58
59
		$helpCommand = new Command\Help($this->_registry, $this->_request, $this->_language, $this->_config);
60
		$formElement = $this->_driver->findElement(WebDriverBy::tagName('form'));
61
		$promptElement = $formElement->findElement(WebDriverBy::id('prompt'));
62
		$boxElement = $this->_driver->findElement(WebDriverBy::id('box'));
63
64
		/* compare */
65
66
		$this->assertNotTrue($boxElement->getText());
67
68
		/* interact and compare */
69
70
		$promptElement->sendKeys('help');
71
		$formElement->submit();
72
		$boxElement->isDisplayed();
73
		$this->assertStringContainsString($helpCommand->getHelp(), $boxElement->getAttribute('textContent'));
74
	}
75
}
76