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

SearchTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 10
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
6
/**
7
 * SearchTest
8
 *
9
 * @since 4.0.0
10
 *
11
 * @package Redaxscript
12
 * @category Tests
13
 * @author Henry Ruhs
14
 */
15
16
class SearchTest extends TestCaseAbstract
17
{
18
	/**
19
	 * setUp
20
	 *
21
	 * @since 4.0.0
22
	 */
23
24
	public function setUp() : void
25
	{
26
		parent::setUp();
27
		$this->_driver->get('http://localhost:8000/?p=search/welcome');
28
	}
29
30
	/**
31
	 * testTitle
32
	 *
33
	 * @since 4.0.0
34
	 */
35
36
	public function testTitle() : void
37
	{
38
		/* expect and actual */
39
40
		$expect = $this->_language->get('search') . ' - ' . $this->_language->get('name', '_package');
41
		$actual = $this->_driver->getTitle();
42
43
		/* compare */
44
45
		$this->assertEquals($expect, $actual);
46
	}
47
48
	/**
49
	 * testSearch
50
	 *
51
	 * @since 4.0.0
52
	 *
53
	 * @param string $url
54
	 * @param array $expectArray
55
	 *
56
	 * @dataProvider providerAutoloader
57
	 */
58
59
	public function testSearch(string $url = null, array $expectArray = []) : void
60
	{
61
		/* setup */
62
63
		$this->_driver->get($url);
64
		$titleElement = $this->_driver->findElement(WebDriverBy::cssSelector('h2.rs-title-result'));
65
		$linkElement = $this->_driver->findElement(WebDriverBy::cssSelector('a.rs-link-result'));
66
67
		/* actual */
68
69
		$actualArray =
70
		[
71
			'title' => $titleElement->getText(),
72
			'link' => $linkElement->getText()
73
		];
74
75
		/* compare */
76
77
		$this->assertEquals($expectArray, $actualArray);
78
	}
79
}
80