|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* (c) FSi sp. z o.o. <[email protected]> |
|
5
|
|
|
* |
|
6
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
7
|
|
|
* file that was distributed with this source code. |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
namespace FSi\Bundle\AdminBundle\Behat\Context\Page; |
|
11
|
|
|
|
|
12
|
|
|
use SensioLabs\Behat\PageObjectExtension\PageObject\Exception\UnexpectedPageException; |
|
13
|
|
|
|
|
14
|
|
|
class SubscribersList extends Page |
|
15
|
|
|
{ |
|
16
|
|
|
protected $path = '/admin/list/subscriber'; |
|
17
|
|
|
|
|
18
|
|
|
public function getHeader() |
|
19
|
|
|
{ |
|
20
|
|
|
return $this->find('css', '#page-header')->getText(); |
|
21
|
|
|
} |
|
22
|
|
|
|
|
23
|
|
|
public function isColumnEditable($columnHeader) |
|
24
|
|
|
{ |
|
25
|
|
|
return $this->getCell($columnHeader, 1)->has('css', 'a.editable'); |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
public function getColumnPosition($columnHeader) |
|
29
|
|
|
{ |
|
30
|
|
|
$headers = $this->findAll('css', 'th'); |
|
31
|
|
|
foreach ($headers as $index => $header) { |
|
32
|
|
|
if ($header->has('css', 'span')) { |
|
33
|
|
|
if ($header->find('css', 'span')->getText() == $columnHeader) { |
|
34
|
|
|
return $index + 1; |
|
35
|
|
|
} |
|
36
|
|
|
} |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
throw new UnexpectedPageException(sprintf("Cant find column %s", $columnHeader)); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
public function getCell($columnHeader, $rowNumber) |
|
43
|
|
|
{ |
|
44
|
|
|
$columnPos = $this->getColumnPosition($columnHeader); |
|
45
|
|
|
return $this->find('xpath', sprintf("descendant-or-self::table/tbody/tr[%d]/td[%d]", $rowNumber, $columnPos)); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
public function getPopover() |
|
49
|
|
|
{ |
|
50
|
|
|
return $this->find('css', 'div.popover-content'); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
protected function verifyPage() |
|
54
|
|
|
{ |
|
55
|
|
|
if (!$this->has('css', '#page-header:contains("List of elements")')) { |
|
56
|
|
|
throw new UnexpectedPageException(sprintf("%s page is missing \"List of elements\" header", $this->path)); |
|
57
|
|
|
} |
|
58
|
|
|
} |
|
59
|
|
|
} |
|
60
|
|
|
|