Fixes some tests due to new metadatum type.
This commit is contained in:
parent
8b8922d240
commit
2253e7dcf0
|
@ -380,7 +380,7 @@ class TAINACAN_REST_Items_Controller extends TAINACAN_UnitApiTestCase {
|
|||
$data = $response->get_data()['items'];
|
||||
|
||||
$this->assertEquals( 2, sizeof($data) );
|
||||
$this->assertEquals( 5, sizeof($data[0]['metadata']) );
|
||||
$this->assertEquals( 7, sizeof($data[0]['metadata']) );
|
||||
|
||||
// Fetch only as admin
|
||||
$request = new \WP_REST_Request(
|
||||
|
|
|
@ -764,10 +764,12 @@ class TAINACAN_REST_Metadata_Controller extends TAINACAN_UnitApiTestCase {
|
|||
|
||||
$response = $this->server->dispatch($requestC);
|
||||
$data = $response->get_data();
|
||||
$this->assertEquals(3, count($data));
|
||||
$this->assertEquals(5, count($data));
|
||||
$this->assertNotEquals($metadatumB->get_id(), $data[0]['id']);
|
||||
$this->assertNotEquals($metadatumB->get_id(), $data[1]['id']);
|
||||
$this->assertNotEquals($metadatumB->get_id(), $data[2]['id']);
|
||||
$this->assertNotEquals($metadatumB->get_id(), $data[3]['id']);
|
||||
$this->assertNotEquals($metadatumB->get_id(), $data[4]['id']);
|
||||
}
|
||||
|
||||
public function test_private_meta_ids_not_in_metadata_order(){
|
||||
|
@ -825,7 +827,7 @@ class TAINACAN_REST_Metadata_Controller extends TAINACAN_UnitApiTestCase {
|
|||
$response = $this->server->dispatch($request);
|
||||
$data = $response->get_data();
|
||||
|
||||
$this->assertEquals(4, count($data['metadata_order']));
|
||||
$this->assertEquals(6, count($data['metadata_order']));
|
||||
|
||||
wp_logout();
|
||||
wp_set_current_user(0);
|
||||
|
@ -835,11 +837,12 @@ class TAINACAN_REST_Metadata_Controller extends TAINACAN_UnitApiTestCase {
|
|||
$response = $this->server->dispatch($request);
|
||||
$data = $response->get_data();
|
||||
|
||||
$this->assertEquals(3, count($data['metadata_order']));
|
||||
$this->assertEquals(5, count($data['metadata_order']));
|
||||
$this->assertNotEquals($metadatumB->get_id(), $data['metadata_order'][0]['id']);
|
||||
$this->assertNotEquals($metadatumB->get_id(), $data['metadata_order'][1]['id']);
|
||||
$this->assertNotEquals($metadatumB->get_id(), $data['metadata_order'][2]['id']);
|
||||
|
||||
$this->assertNotEquals($metadatumB->get_id(), $data['metadata_order'][3]['id']);
|
||||
$this->assertNotEquals($metadatumB->get_id(), $data['metadata_order'][4]['id']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -502,25 +502,25 @@ class Capabilities extends TAINACAN_UnitTestCase {
|
|||
wp_set_current_user($this->subscriber2->ID);
|
||||
|
||||
$meta = tainacan_metadata()->fetch_by_collection($this->public_collection);
|
||||
$this->AssertEquals(4, sizeof($meta));
|
||||
$this->AssertEquals(6, sizeof($meta));
|
||||
$meta = tainacan_metadata()->fetch_ids_by_collection($this->public_collection);
|
||||
$this->AssertEquals(4, sizeof($meta));
|
||||
$this->AssertEquals(6, sizeof($meta));
|
||||
|
||||
$this->subscriber2->add_cap( 'tnc_col_' . $this->public_collection->get_id() . '_read_private_metadata' );
|
||||
$current_user = $this->subscriber2; // force update current user object with new capabilities
|
||||
|
||||
$meta = tainacan_metadata()->fetch_by_collection($this->public_collection);
|
||||
$this->AssertEquals(5, sizeof($meta));
|
||||
$this->AssertEquals(7, sizeof($meta));
|
||||
$meta = tainacan_metadata()->fetch_ids_by_collection($this->public_collection);
|
||||
$this->AssertEquals(5, sizeof($meta));
|
||||
$this->AssertEquals(7, sizeof($meta));
|
||||
|
||||
$this->subscriber2->add_cap( 'tnc_rep_read_private_metadata' );
|
||||
$current_user = $this->subscriber2; // force update current user object with new capabilities
|
||||
|
||||
$meta = tainacan_metadata()->fetch_by_collection($this->public_collection);
|
||||
$this->AssertEquals(6, sizeof($meta));
|
||||
$this->AssertEquals(8, sizeof($meta));
|
||||
$meta = tainacan_metadata()->fetch_ids_by_collection($this->public_collection);
|
||||
$this->AssertEquals(6, sizeof($meta));
|
||||
$this->AssertEquals(8, sizeof($meta));
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -240,7 +240,7 @@ class Item_Metadata extends TAINACAN_UnitTestCase {
|
|||
$this->assertTrue(is_array($item_metadatas));
|
||||
|
||||
// notice for repository metadata
|
||||
$this->assertEquals(3, sizeof($item_metadatas));
|
||||
$this->assertEquals(5, sizeof($item_metadatas));
|
||||
//first 2 metadata are repository metadata
|
||||
$this->assertTrue( in_array('metadado', $names) );
|
||||
|
||||
|
|
|
@ -165,8 +165,8 @@ class Metadata extends TAINACAN_UnitTestCase {
|
|||
$retrieve_metadata_ids = $Tainacan_Metadata->fetch_ids_by_collection( $collection_son, [] );
|
||||
|
||||
// should return 6
|
||||
$this->assertEquals( 6, sizeof( $retrieve_metadata ) );
|
||||
$this->assertEquals( 6, sizeof( $retrieve_metadata_ids ) );
|
||||
$this->assertEquals( 8, sizeof( $retrieve_metadata ) );
|
||||
$this->assertEquals( 8, sizeof( $retrieve_metadata_ids ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -197,7 +197,7 @@ class Metadata extends TAINACAN_UnitTestCase {
|
|||
*/
|
||||
function test_metadata_metadata_type(){
|
||||
$Tainacan_Metadata = \Tainacan\Repositories\Metadata::get_instance();
|
||||
$this->assertEquals( 9, sizeof( $Tainacan_Metadata->fetch_metadata_types() ) );
|
||||
$this->assertEquals( 10, sizeof( $Tainacan_Metadata->fetch_metadata_types() ) );
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue