Add unit test to remove metadata
This commit is contained in:
@@ -6,6 +6,7 @@ New features:
|
|||||||
- Added support of user mentions (@username)
|
- Added support of user mentions (@username)
|
||||||
- Added report to compare working hours between open and closed tasks
|
- Added report to compare working hours between open and closed tasks
|
||||||
- Added the possiblity to define custom routes from plugins
|
- Added the possiblity to define custom routes from plugins
|
||||||
|
- Added new method to remove metadata
|
||||||
|
|
||||||
Improvements:
|
Improvements:
|
||||||
|
|
||||||
|
|||||||
@@ -106,16 +106,6 @@ abstract class Metadata extends Base
|
|||||||
*/
|
*/
|
||||||
public function remove($entity_id, $name)
|
public function remove($entity_id, $name)
|
||||||
{
|
{
|
||||||
|
return $this->db->table(static::TABLE)->eq($this->getEntityKey(), $entity_id)->eq('name', $name)->remove();
|
||||||
$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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,6 +30,11 @@ class ProjectMetadataTest extends Base
|
|||||||
|
|
||||||
$this->assertEquals(array('key1' => 'value2'), $pm->getAll(1));
|
$this->assertEquals(array('key1' => 'value2'), $pm->getAll(1));
|
||||||
$this->assertEquals(array('key1' => 'value1', 'key2' => 'value2'), $pm->getAll(2));
|
$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()
|
public function testAutomaticRemove()
|
||||||
|
|||||||
@@ -33,5 +33,10 @@ class TaskMetadataTest extends Base
|
|||||||
|
|
||||||
$this->assertEquals(array('key1' => 'value2'), $tm->getAll(1));
|
$this->assertEquals(array('key1' => 'value2'), $tm->getAll(1));
|
||||||
$this->assertEquals(array('key1' => 'value1', 'key2' => 'value2'), $tm->getAll(2));
|
$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' => 'value2'), $m->getAll(1));
|
||||||
$this->assertEquals(array('key1' => 'value1', 'key2' => 'value2'), $m->getAll(2));
|
$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