getTags() public method

public getTags ( ) : array
return array
示例#1
0
 public function testItem()
 {
     $item = new Item();
     $date = new DateTime();
     $item->setId('id');
     $item->setName('name');
     $item->setIntro('intro');
     $item->setContent('content');
     $item->setSource('source');
     $item->setAuthor('author');
     $item->setImage('image');
     $item->setDate($date);
     $item->setExtra('key', 'value');
     $item->setTags(array('tag'));
     $this->assertEquals('id', $item->getId());
     $this->assertEquals('name', $item->getName());
     $this->assertEquals('intro', $item->getIntro());
     $this->assertEquals('content', $item->getContent());
     $this->assertEquals('source', $item->getSource());
     $this->assertEquals('author', $item->getAuthor());
     $this->assertEquals('image', $item->getImage());
     $this->assertEquals($date, $item->getDate());
     $this->assertEquals('value', $item->getExtra('key'));
     $this->assertEquals(null, $item->getExtra('key-no-exist'));
     $this->assertEquals(array('tag'), $item->getTags());
 }
 /**
  * @dataProvider dataProvider
  */
 public function testTags(Item $item, $content, $fileName)
 {
     $expected = $this->getFirstValueFromXpath($content, "*/item[1]/category");
     $tags = $item->getTags();
     if (!$expected) {
         $this->assertCount(0, $item->getTags(), 'Fail asserting that first element of ' . $fileName . ' has no tags');
         return;
     }
     $this->assertEquals($expected, array_shift($tags), 'Fail asserting that first element of ' . $fileName . ' has first tag "' . $expected . '"');
 }