Example #1
0
 public function testAddAndGetDocuments()
 {
     $doc1 = new ReadOnlyDocument(array('id' => 1));
     $doc2 = new ReadOnlyDocument(array('id' => 2));
     $this->query->addDocuments(array($doc1, $doc2));
     $this->assertEquals(array($doc1, $doc2), $this->query->getDocuments());
 }
 public function testGetRawData()
 {
     // this doc tests data escaping
     $doc1 = new InputDocument(array('id' => 1, 'name' => 'doc1', 'cat' => 'my > cat'));
     // this doc tests a multivalue field
     $doc2 = new InputDocument(array('id' => 2, 'name' => 'doc2', 'cat' => array(1, 2, 3)));
     $this->query->addDocuments(array($doc1, $doc2));
     $this->assertEquals('<docs><doc><field name="id">1</field><field name="name">doc1</field><field name="cat">my &gt; cat</field></doc><doc><field name="id">2</field><field name="name">doc2</field><field name="cat">1</field><field name="cat">2</field><field name="cat">3</field></doc></docs>', $this->builder->getRawData($this->query));
 }