fix and test deleting entities attributes

This commit is contained in:
Leo Germani 2018-02-09 16:04:39 -02:00
parent 7a421dc4bb
commit dbc3349d46
3 changed files with 27 additions and 3 deletions

View File

@ -129,7 +129,7 @@ class Entity {
* @return mixed property value
*/
public function get_mapped_property($prop) {
if (isset($this->$prop) && !empty($this->$prop)){
if (isset($this->$prop) ){
return $this->$prop;
}
//prop is not set at object, try to get from database

View File

@ -22,9 +22,10 @@ class Term extends Entity {
* @param int $which
* @param string $taxonomy
*/
function __construct($which = 0, $taxonomy = '' ) {
function __construct($which = 0, $taxonomy = false ) {
$this->set_taxonomy( $taxonomy );
if ($taxonomy)
$this->set_taxonomy( $taxonomy );
if ( is_numeric( $which ) && $which > 0) {
$post = get_term_by('id', $which, $taxonomy);

View File

@ -111,4 +111,27 @@ class Objects extends TAINACAN_UnitTestCase {
$entity = Repository::get_entity_by_post($test);
$this->assertEquals($item_metadata->get_field()->get_db_identifier(), $entity->get_db_identifier());
}
function test_delete_attributes() {
$collection = $this->tainacan_entity_factory->create_entity(
'collection',
array(
'name' => 'test title',
'description' => 'test description',
'status' => 'draft'
),
true
);
$collection->set_name('');
$this->assertEquals('', $collection->get_name());
global $Tainacan_Collections;
$this->assertTrue($collection->validate());
$newCol = $Tainacan_Collections->insert($collection);
$this->assertEquals('', $newCol->get_name());
}
}