Completed
Push — master ( de9e2d...f59dfb )
by Henry
08:37
created

LoginTest::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 Facebook\WebDriver\WebDriverExpectedCondition;
6
7
/**
8
 * LoginTest
9
 *
10
 * @since 4.0.0
11
 *
12
 * @package Redaxscript
13
 * @category Tests
14
 * @author Henry Ruhs
15
 */
16
17
class LoginTest extends TestCaseAbstract
18
{
19
	/**
20
	 * setUp
21
	 *
22
	 * @since 4.0.0
23
	 */
24
25
	public function setUp()
26
	{
27
		parent::setUp();
28
		$this->_driver->get('http://localhost:8000/?p=login');
29
	}
30
31
	/**
32
	 * testTitle
33
	 *
34
	 * @since 4.0.0
35
	 */
36
37
	public function testTitle()
38
	{
39
		/* expect and actual */
40
41
		$expect = $this->_language->get('login') . $this->_language->get('divider') . $this->_language->get('name', '_package');
42
		$actual = $this->_driver->getTitle();
43
44
		/* compare */
45
46
		$this->assertEquals($expect, $actual);
47
	}
48
49
	/**
50
	 * testLogin
51
	 *
52
	 * @since 4.0.0
53
	 */
54
55
	public function testLogin()
56
	{
57
		/* prepare */
58
59
		$formElement = $this->_driver->findElement(WebDriverBy::tagName('form'));
60
		$userElement = $formElement->findElement(WebDriverBy::id('user'));
61
		$passwordElement = $formElement->findElement(WebDriverBy::id('password'));
62
		$buttonElement = $formElement->findElement(WebDriverBy::tagName('button'));
63
64
		/* setup */
65
66
		$userElement->sendKeys('test');
67
		$passwordElement->sendKeys('test');
68
		$buttonElement->click();
69
70
		/* compare */
71
72
		$this->_driver->wait(5)->until(WebDriverExpectedCondition::urlIs('http://localhost:8000/?p=admin'));
73
		$this->expectNotToPerformAssertions();
74
	}
75
}
76