Development

#6686: idDoctrineTestBrowser.class.2.php

You must first sign up to be able to contribute.

Ticket #6686: idDoctrineTestBrowser.class.2.php

File idDoctrineTestBrowser.class.2.php, 1.6 kB (added by fullo, 3 years ago)

the extended sfTestBrowser

Line 
1 <?php
2 /**
3  * This file is part of the phpCollab3 package.
4  * (c) 2009 Ideato s.r.l. <phpcollab@ideato.it>
5  *
6  * For the full copyright and license information, please view the LICENSE
7  * file that was distributed with this source code.
8  *
9  * idDoctrineTestBrowser.class.php
10  *
11  * @package    phpCollab3
12  * @subpackage idProjectManagmentPlugin Test
13  */
14
15 /**
16  * idDoctrineTestBrowser
17  *
18  * Extends the standard sfTestFunctional class to add doctrine fixtures loading methods
19  *
20  * @package    phpCollab3
21  * @subpackage idProjectManagmentPlugin Test
22  * @author     Filippo (p16) De Santis <fd@ideato.it>
23  * @author     Francesco Fullone <ff@ideato.it>
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 }