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

SearchTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 64
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 5 1
A testTitle() 0 11 1
A testSearch() 0 20 1
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