| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
class idDoctrineTestBrowser extends sfBrowser { |
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 |
* Deselect otion of a select given a select name/id and the option value to deselect. |
|---|
| 29 |
* |
|---|
| 30 |
* @param string $name select name/id |
|---|
| 31 |
* @param string $option_value option value to be deselected |
|---|
| 32 |
* @return idDoctrineTestBrowser |
|---|
| 33 |
*/ |
|---|
| 34 |
public function deSelectOption($name, $option_value) |
|---|
| 35 |
{ |
|---|
| 36 |
$position = 0; |
|---|
| 37 |
$dom = $this->getResponseDom(); |
|---|
| 38 |
|
|---|
| 39 |
if (!$dom) |
|---|
| 40 |
{ |
|---|
| 41 |
throw new LogicException('Cannot select because there is no current page in the browser.'); |
|---|
| 42 |
} |
|---|
| 43 |
|
|---|
| 44 |
$xpath = new DomXpath($dom); |
|---|
| 45 |
|
|---|
| 46 |
if ($element = $xpath->query(sprintf('//select[(.="%s" or @id="%s" or @name="%s")]/option[@value="%s"]', $name, $name, $name, $option_value))->item($position)) |
|---|
| 47 |
{ |
|---|
| 48 |
$element->removeAttribute('selected'); |
|---|
| 49 |
} |
|---|
| 50 |
else |
|---|
| 51 |
{ |
|---|
| 52 |
throw new InvalidArgumentException(sprintf('Cannot find the select (%s) option value "%s" .', $name, $option_value)); |
|---|
| 53 |
} |
|---|
| 54 |
|
|---|
| 55 |
return $this; |
|---|
| 56 |
} |
|---|
| 57 |
|
|---|
| 58 |
} |
|---|