Exemple #1
0
 /**
  * Tests the is_available_for_all() function.
  */
 public function test_is_available_for_all()
 {
     // Empty tree is always available.
     $structure = tree::get_root_json(array(), tree::OP_OR);
     $tree = new tree($structure);
     $this->assertTrue($tree->is_available_for_all());
     // Tree with normal item in it, not always available.
     $structure->c[0] = (object) array('type' => 'mock');
     $tree = new tree($structure);
     $this->assertFalse($tree->is_available_for_all());
     // OR tree with one always-available item.
     $structure->c[1] = self::mock(array('all' => true));
     $tree = new tree($structure);
     $this->assertTrue($tree->is_available_for_all());
     // AND tree with one always-available and one not.
     $structure->op = '&';
     $structure->showc = array(true, true);
     unset($structure->show);
     $tree = new tree($structure);
     $this->assertFalse($tree->is_available_for_all());
     // Test NOT conditions (items not always-available).
     $structure->op = '!&';
     $structure->show = true;
     unset($structure->showc);
     $tree = new tree($structure);
     $this->assertFalse($tree->is_available_for_all());
     // Test again with one item always-available for NOT mode.
     $structure->c[1]->allnot = true;
     $tree = new tree($structure);
     $this->assertTrue($tree->is_available_for_all());
 }