public function test_DefaultConfigPage()
 {
     $drv = $this->getDriver()->get($this->getSiteUrl() . '/config');
     $cfg = json_decode(Configuration::DEFAULT_CONFIG_JSON, true);
     $SUPPORTED_VALUES = Configuration::SUPPORTED_VALUES;
     //PDT 3.4 fails to understand const array support. TODO: bug report
     $this->assertEquals('MyLibrary ~ Configuration', $drv->getTitle());
     // === SELECTS ===
     //
     //-- system_language
     $el = new Select($drv->findElement(By::xpath("//select[@name='system_language']")));
     $this->assertEquals($cfg['system']['language'], $el->getFirstSelectedOption()->getAttribute('value'));
     //def value
     $this->assertEquals($SUPPORTED_VALUES['system_language'][$cfg['system']['language']], $el->getFirstSelectedOption()->getText());
     //def txt
     // all options TODO: as function
     foreach ($SUPPORTED_VALUES['system_language'] as $k => $v) {
         $found = false;
         foreach ($el->getOptions() as $opt) {
             if ($opt->getAttribute('value') == $k) {
                 if ($opt->getText() != $v) {
                     $this->fail("value '{$k}' mached, but visible config text '{$v}' does not match on page '" . $opt->getText() . "'");
                 }
                 $found = true;
                 break;
             }
         }
         if (!$found) {
             $this->fail("value {$k} was not generated on page");
         }
     }
     //
     //-- system_theme
     $el = new Select($drv->findElement(By::xpath("//select[@name='system_theme']")));
     $this->assertEquals($cfg['system']['theme'], $el->getFirstSelectedOption()->getAttribute('value'));
     //def value
     $this->assertEquals($cfg['system']['theme'], $el->getFirstSelectedOption()->getText());
     //def txt, equals to value
     //
     //-- system_timezone
     $el = new Select($drv->findElement(By::xpath("//select[@name='system_timezone']")));
     $this->assertEquals($cfg['system']['timezone'], $el->getFirstSelectedOption()->getAttribute('value'));
     //def value
     $this->assertEquals($cfg['system']['timezone'], $el->getFirstSelectedOption()->getText());
     //def txt, equals to value
 }
 private function checkTestField($field, $value = NULL)
 {
     $field = strtolower($field);
     if ($value === NULL) {
         $value = TestFixtures::$tests['test-1']->{"get" . ucfirst($field)}();
     }
     if ($field === "expectation") {
         $select = new WebDriverSelect($this->getTestField('expectation'));
         $this->assertEquals($value, $select->getFirstSelectedOption()->getText());
         return;
     }
     $this->assertEquals($value, $this->getTestField($field)->getAttribute('value'));
 }
Exemple #3
0
 public function grabValueFrom($field)
 {
     $el = $this->findField($field);
     // value of multiple select is the value of the first selected option
     if ($el->getTagName() == 'select') {
         $select = new WebDriverSelect($el);
         return $select->getFirstSelectedOption()->getAttribute('value');
     }
     return $el->getAttribute('value');
 }