Esempio n. 1
0
 public function testConfigModeMultiValue()
 {
     $options = array('id' => array(1, 2), 'query' => array('id:1', 'id:2'));
     $command = new Delete($options);
     $this->assertEquals(array(1, 2), $command->getIds());
     $this->assertEquals(array('id:1', 'id:2'), $command->getQueries());
 }
Esempio n. 2
0
 /**
  * Convenience method to add a delete by IDs command.
  *
  * If you need more control, like choosing a key for the command you need to
  * create you own command instance and use the add method.
  *
  * @param array $ids
  *
  * @return self Provides fluent interface
  */
 public function addDeleteByIds($ids)
 {
     $delete = new DeleteCommand();
     $delete->addIds($ids);
     return $this->add(null, $delete);
 }
 /**
  * Build XML for a delete command
  *
  * @param  Query\Command\Delete $command
  * @return string
  */
 public function buildDeleteXml($command)
 {
     $xml = '<delete>';
     foreach ($command->getIds() as $id) {
         $xml .= '<id>' . htmlspecialchars($id, ENT_NOQUOTES, 'UTF-8') . '</id>';
     }
     foreach ($command->getQueries() as $query) {
         $xml .= '<query>' . htmlspecialchars($query, ENT_NOQUOTES, 'UTF-8') . '</query>';
     }
     $xml .= '</delete>';
     return $xml;
 }
Esempio n. 4
0
 public function testBuildDeleteXmlIdAndQuerySpecialChars()
 {
     $command = new DeleteCommand();
     $command->addId('special<char>id');
     $command->addQuery('id:special<char>id');
     $this->assertEquals('<delete><id>special&lt;char&gt;id</id><query>id:special&lt;char&gt;id</query></delete>', $this->builder->buildDeleteXml($command));
 }