Fix the unit test by running tearDown() and cleaning tags before the test
This commit is contained in:
parent
1d0c041ac8
commit
08d07cc4db
|
@ -40,9 +40,15 @@ class SystemTagManagerTest extends TestCase {
|
|||
|
||||
$this->connection = \OC::$server->getDatabaseConnection();
|
||||
$this->tagManager = new SystemTagManager($this->connection);
|
||||
$this->pruneTagsTables();
|
||||
}
|
||||
|
||||
public function tearDown() {
|
||||
$this->pruneTagsTables();
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
protected function pruneTagsTables() {
|
||||
$query = $this->connection->getQueryBuilder();
|
||||
$query->delete(SystemTagObjectMapper::RELATION_TABLE)->execute();
|
||||
$query->delete(SystemTagManager::TAG_TABLE)->execute();
|
||||
|
|
|
@ -62,6 +62,7 @@ class SystemTagObjectMapperTest extends TestCase {
|
|||
parent::setUp();
|
||||
|
||||
$this->connection = \OC::$server->getDatabaseConnection();
|
||||
$this->pruneTagsTables();
|
||||
|
||||
$this->tagManager = $this->getMockBuilder('OCP\SystemTag\ISystemTagManager')
|
||||
->getMock();
|
||||
|
@ -92,9 +93,14 @@ class SystemTagObjectMapperTest extends TestCase {
|
|||
$this->tagMapper->assignTags(1, 'testtype', $this->tag2->getId());
|
||||
$this->tagMapper->assignTags(2, 'testtype', $this->tag1->getId());
|
||||
$this->tagMapper->assignTags(3, 'anothertype', $this->tag1->getId());
|
||||
}
|
||||
}
|
||||
|
||||
public function tearDown() {
|
||||
$this->pruneTagsTables();
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
protected function pruneTagsTables() {
|
||||
$query = $this->connection->getQueryBuilder();
|
||||
$query->delete(SystemTagObjectMapper::RELATION_TABLE)->execute();
|
||||
$query->delete(SystemTagManager::TAG_TABLE)->execute();
|
||||
|
|
Loading…
Reference in New Issue