protected function renderStack($stack)
 {
     if (empty($stack)) {
         return '';
     }
     $html = '<ul>';
     $firstLevel = $prevLevel = $stack[0]['level'];
     $stackLength = count($stack);
     foreach ($stack as $key => $header) {
         $level = $header['level'];
         $nextLevel = $key < $stackLength - 1 ? $stack[$key + 1]['level'] : $firstLevel;
         $link = '<a href="#' . $header['id'] . '">' . $header['text'] . '</a>';
         if ($level === $prevLevel) {
             $html .= '<li>' . $link;
             $html .= $level < $nextLevel ? '' : '</li>';
         } elseif ($level < $prevLevel) {
             $html .= str_repeat('</ul></li>', $prevLevel - $level) . '<li>' . $link;
             $html .= $level < $nextLevel ? '' : '</li>';
         } elseif ($level > $prevLevel) {
             $html .= '<ul><li>' . $link;
             $html .= $level < $nextLevel ? '' : '</li>';
         }
         $prevLevel = $level;
     }
     $html .= str_repeat('</ul></li>', $level - $firstLevel);
     $html .= '</ul>';
     return $html;
     $html = str_replace('>', ">\n", $html);
     dmDebug::kill($html);
 }
Beispiel #2
0
    $cat2 = $po->getRelatedRecord('DmTestCateg');
    $t->is((string) $cat1, (string) $cat2, sprintf('post %d related categ : %s / %s', $po->id, $cat1 ? $cat1->id : 'NULL', $cat2 ? $cat2->id : 'NULL'));
}
$t->diag('Related record test : verifying that we get the first related record in reversed local relation');
foreach (dmDb::table('DmTestCateg')->findAll() as $cat) {
    $post1 = $cat->Posts[0]->orNull();
    $post2 = $cat->getRelatedRecord('DmTestPost');
    $t->is((string) $post1, (string) $post2, sprintf('categ %d related post : %s / %s', $cat->id, $post1 ? $post1->id : 'NULL', $post2 ? $post2->id : 'NULL'));
}
$t->diag('Related record test : verifying that we get the first related record in association relation');
foreach (dmDb::table('DmTestCateg')->findAll() as $cat) {
    $dom1 = $cat->Domains[0]->orNull();
    $dom2 = $cat->getRelatedRecord('DmTestDomain');
    $t->is((string) $dom1, (string) $dom2, sprintf('categ %d related domain : %s / %s', $cat->id, $dom1 ? $dom1->id : 'NULL', $dom2 ? $dom2->id : 'NULL'));
    if ($dom1 != $dom2) {
        dmDebug::kill($cat->Domains, $cat->getRelatedRecord('DmTestDomain'));
    }
}
$t->diag('Related record test : verifying that we get the first related record in reverse association relation');
foreach (dmDb::table('DmTestDomain')->findAll() as $dom) {
    $cat1 = $dom->Categs[0]->orNull();
    $cat2 = $dom->getRelatedRecord('DmTestCateg');
    $t->is((string) $cat1, (string) $cat2, sprintf('domain %d related categ : %s / %s', $dom->id, $cat1 ? $cat1->id : 'NULL', $cat2 ? $cat2->id : 'NULL'));
}
$t->diag('Related record test : verifying that we get the first related record in another association relation');
foreach (dmDb::table('DmTestTag')->findAll() as $_tag) {
    $post1 = $_tag->Posts[0]->orNull();
    $post2 = $_tag->getRelatedRecord('DmTestPost');
    $t->is((string) $post1, (string) $post2, sprintf('tag %d related post : %s / %s', $_tag->id, $post1 ? $post1->id : 'NULL', $post2 ? $post2->id : 'NULL'));
}
//$t->diag('Related record id tests');
Beispiel #3
0
 protected function checkEachRecordChildrenHavePage($module, $t)
 {
     $errors = array();
     /*
      * Test only leaf modules
      */
     if ($module->hasChildren()) {
         return $errors;
     }
     if ($ancestorModule = $module->getFarthestAncestorWithPage()) {
         $ancestorModel = $ancestorModule->getModel();
     } else {
         return $errors;
     }
     /*
      * Verify that each record wich has an ancestor has a page
      */
     $records = new myDoctrineCollection($module->getTable());
     foreach ($ancestorModule->getTable()->findAll() as $ancestorRecord) {
         $records = $records->merge($module->getTable()->createQuery('r')->whereAncestor($ancestorRecord, $module->getModel())->fetchRecords());
     }
     foreach ($records as $record) {
         if (!$record->getDmPage()) {
             $error = sprintf('%s %d %s has no page', $module, $record->id, $record);
             $t->diag($error);
             $errors[] = $error;
         }
     }
     if (count($errors)) {
         $t->diag('Error !');
         dmDebug::kill($errors);
     }
     return $errors;
 }