コード例 #1
0
 public function testTagCollection()
 {
     $material = new material();
     $this->assertFalse($material->containsTag('t'));
     $material->addTag('t');
     $this->assertTrue($material->containsTag('t'));
     $material->removeTag('t');
     $this->assertFalse($material->containsTag('t'));
     //Repeat Tag
     $this->assertFalse($material->containsTag('t'));
     $material->addTag('t');
     $material->addTag('t');
     $this->assertTrue($material->containsTag('t'));
     $material->removeTag('t');
     $this->assertFalse($material->containsTag('t'));
     $this->assertFalse($material->removeTag('t'));
     //containsAllTag and containsAnyTag
     $material->addTag('t1');
     $material->addTag('t2');
     $material->addTag('t3');
     $this->assertTrue($material->containsAnyTag(array('t0', 't2')));
     $this->assertTrue($material->containsAnyTag(array('t2', 't3')));
     $this->assertFalse($material->containsAnyTag(array('t0', 't4')));
     $this->assertTrue($material->containsAllTags(array('t1', 't2')));
     $this->assertTrue($material->containsAllTags(array('t1')));
     $this->assertFalse($material->containsAllTags(array('t0', 't2')));
     $this->assertFalse($material->containsAllTags(array('t0', 't1', 't2', 't3')));
 }