Add unit test to remove metadata
This commit is contained in:
@@ -6,6 +6,7 @@ New features:
|
||||
- Added support of user mentions (@username)
|
||||
- Added report to compare working hours between open and closed tasks
|
||||
- Added the possiblity to define custom routes from plugins
|
||||
- Added new method to remove metadata
|
||||
|
||||
Improvements:
|
||||
|
||||
|
||||
@@ -101,21 +101,11 @@ abstract class Metadata extends Base
|
||||
*
|
||||
* @access public
|
||||
* @param integer $entity_id
|
||||
* @param string $name
|
||||
* @param string $name
|
||||
* @return bool
|
||||
*/
|
||||
public function remove($entity_id, $name)
|
||||
{
|
||||
|
||||
$this->db->startTransaction();
|
||||
|
||||
if (! $this->db->table(static::TABLE)->eq($this->getEntityKey(), $entity_id)->eq('name', $name)->remove()) {
|
||||
$this->db->cancelTransaction();
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->db->closeTransaction();
|
||||
|
||||
return true;
|
||||
return $this->db->table(static::TABLE)->eq($this->getEntityKey(), $entity_id)->eq('name', $name)->remove();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,11 @@ class ProjectMetadataTest extends Base
|
||||
|
||||
$this->assertEquals(array('key1' => 'value2'), $pm->getAll(1));
|
||||
$this->assertEquals(array('key1' => 'value1', 'key2' => 'value2'), $pm->getAll(2));
|
||||
|
||||
$this->assertTrue($pm->remove(2, 'key1'));
|
||||
$this->assertFalse($pm->remove(2, 'key1'));
|
||||
|
||||
$this->assertEquals(array('key2' => 'value2'), $pm->getAll(2));
|
||||
}
|
||||
|
||||
public function testAutomaticRemove()
|
||||
|
||||
@@ -33,5 +33,10 @@ class TaskMetadataTest extends Base
|
||||
|
||||
$this->assertEquals(array('key1' => 'value2'), $tm->getAll(1));
|
||||
$this->assertEquals(array('key1' => 'value1', 'key2' => 'value2'), $tm->getAll(2));
|
||||
|
||||
$this->assertTrue($tm->remove(2, 'key1'));
|
||||
$this->assertFalse($tm->remove(2, 'key1'));
|
||||
|
||||
$this->assertEquals(array('key2' => 'value2'), $tm->getAll(2));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,5 +29,10 @@ class UserMetadataTest extends Base
|
||||
|
||||
$this->assertEquals(array('key1' => 'value2'), $m->getAll(1));
|
||||
$this->assertEquals(array('key1' => 'value1', 'key2' => 'value2'), $m->getAll(2));
|
||||
|
||||
$this->assertTrue($m->remove(2, 'key1'));
|
||||
$this->assertFalse($m->remove(2, 'key1'));
|
||||
|
||||
$this->assertEquals(array('key2' => 'value2'), $m->getAll(2));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user