Ejemplo n.º 1
0
 /**
  * @test
  */
 public function findAllSectionThatMatchCertainCriteria()
 {
     $this->obj->flush();
     $section = new Section();
     $section->id = 17;
     $section->volume = 1;
     $section->title = "Chapter 17";
     $section->page = 17;
     $section->level = 3;
     $section->element = 'div';
     $this->obj->save($section);
     $section = new Section();
     $section->id = 23;
     $section->volume = 2;
     $section->title = "Chapter 23";
     $section->page = 180;
     $section->level = 2;
     $section->element = 'div';
     $this->obj->save($section);
     $objs = $this->obj->find('id = 23');
     $this->assertInternalType('array', $objs);
     $this->assertSame(1, count($objs));
     $this->assertEquals(2, $objs[0]->volume);
     $objs = $this->obj->find('title = Chapter');
     $this->assertInternalType('array', $objs);
     $this->assertSame(0, count($objs));
     $objs = $this->obj->find('title~ Chapter%');
     $this->assertInternalType('array', $objs);
     $this->assertSame(2, count($objs));
     $objs = $this->obj->find('page >= 17');
     $this->assertInternalType('array', $objs);
     $this->assertSame(2, count($objs));
 }
Ejemplo n.º 2
0
 /**
  * Method which will called when a new section is encountered.
  */
 protected function newSection()
 {
     if ('text' == $this->r->localName or 'front' == $this->r->localName) {
         // <text> must not contain <head>, hence there is no title
         $title = '';
     } elseif ('titlePage' == $this->r->localName) {
         $title = $this->titlePageLabel;
     } else {
         $title = $this->titleExtractor->extractTitle($this->r->readOuterXML());
     }
     $section = $this->setup->factory->createSection();
     $section->id = $this->currentSection;
     $section->volume = $this->data['currentVolume'];
     $section->title = $title;
     $section->page = $this->page ? $this->page : 1;
     $section->level = $this->level;
     $section->element = $this->r->localName;
     $section->xmlid = $this->r->getAttribute('xml:id');
     $this->sectionGateway->save($section);
 }