コード例 #1
0
ファイル: TOCTest.php プロジェクト: kaantunc/MYK-BOR
 /**
  * Add and get title
  */
 public function testAddAndGetTitle()
 {
     $titleCount = 3;
     $anchor = '_Toc' . (252634154 + $titleCount);
     $bookmark = $titleCount - 1;
     $titles = array('Heading 1' => 1, 'Heading 2' => 2, 'Heading 3' => 3);
     $toc = new TOC();
     foreach ($titles as $text => $depth) {
         $response = $toc->addTitle($text, $depth);
     }
     $this->assertEquals($anchor, $response[0]);
     $this->assertEquals($bookmark, $response[1]);
     $i = 0;
     $savedTitles = $toc->getTitles();
     foreach ($titles as $text => $depth) {
         $this->assertEquals($text, $savedTitles[$i]['text']);
         $this->assertEquals($depth, $savedTitles[$i]['depth']);
         $i++;
     }
     TOC::resetTitles();
     $this->assertEquals(0, count($toc->getTitles()));
 }
コード例 #2
0
ファイル: TOC.php プロジェクト: kaantunc/MYK-BOR
 /**
  * Get all titles
  *
  * @return array
  */
 public function getTitles()
 {
     $titles = Titles::getTitles();
     foreach ($titles as $i => $title) {
         if ($this->minDepth > $title['depth']) {
             unset($titles[$i]);
         }
         if ($this->maxDepth != 0 && $this->maxDepth < $title['depth']) {
             unset($titles[$i]);
         }
     }
     $titles = array_merge(array(), $titles);
     return $titles;
 }