fix and test deleting entities attributes
This commit is contained in:
parent
7a421dc4bb
commit
dbc3349d46
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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());
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue