public function testOpenSearchSearchUrl()
 {
     $xml = $this->getRequest('api/opensearch.php')->send()->getBody();
     $x = simplexml_load_string($xml);
     $x->registerXPathNamespace('os', rreset($x->getDocNamespaces()));
     $arElements = $x->xpath('//os:Url[@type="text/html"]');
     $this->assertEquals(1, count($arElements), 'Url in OpenSearch description is missing');
     $this->assertEquals($GLOBALS['unittestUrl'] . 'search.php/all/{searchTerms}', (string) $arElements[0]['template']);
 }
 /**
  * Converts a string of CSV data to an array
  *
  * @param string $body String containing the full CSV file
  *
  * @return array Array of CSV data
  */
 protected function getCsvArray($body)
 {
     $v53 = version_compare(PHP_VERSION, '5.3.0') === 1;
     //dead simple implementation that does not work with
     // advanced CSV files
     $ar = array();
     foreach (explode("\n", $body) as $line) {
         if ($v53) {
             $ar[] = str_getcsv($line, ';');
         } else {
             $arl = explode(';', $line);
             foreach ($arl as &$str) {
                 if (substr($str, 0, 1) == '"' && substr($str, -1) == '"') {
                     $str = substr($str, 1, -1);
                 }
             }
             $ar[] = $arl;
         }
     }
     if (count(end($ar)) == 1 && rreset(end($ar)) == '') {
         unset($ar[key($ar)]);
     }
     return $ar;
 }
Esempio n. 3
0
 /**
  * Creates a new user in the database.
  *
  * @param string $username   Username, may be null
  * @param string $password   Password, may be null
  * @param mixed  $privateKey String private key or boolean true to generate one
  *
  * @return integer ID of user
  *
  * @uses addUserData()
  */
 protected function addUser($username = null, $password = null, $privateKey = null)
 {
     return rreset($this->addUserData($username, $password, $privateKey));
 }