fix collections api test and new test for unique slugs
This commit is contained in:
parent
b201c4ba17
commit
4825cc3469
|
@ -87,11 +87,11 @@ class TAINACAN_REST_Collections_Controller extends TAINACAN_UnitApiTestCase {
|
||||||
//$data is a valid json?
|
//$data is a valid json?
|
||||||
//$this->assertTrue(json_last_error() === JSON_ERROR_NONE);
|
//$this->assertTrue(json_last_error() === JSON_ERROR_NONE);
|
||||||
|
|
||||||
$other_collection = $data[0];
|
$collectionsNames = array_map(function($data) {return $data['name'];}, $data);
|
||||||
$one_collection = $data[1];
|
|
||||||
|
$this->assertContains('testeApi', $collectionsNames);
|
||||||
|
$this->assertContains('Other', $collectionsNames);
|
||||||
|
|
||||||
$this->assertEquals('testeApi', $one_collection['name']);
|
|
||||||
$this->assertEquals('Other', $other_collection['name']);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_delete_or_trash_a_collection(){
|
public function test_delete_or_trash_a_collection(){
|
||||||
|
|
|
@ -158,6 +158,70 @@ class Collections extends TAINACAN_UnitTestCase {
|
||||||
$this->assertEquals('draft', $test->get_status());
|
$this->assertEquals('draft', $test->get_status());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function test_unique_slugs() {
|
||||||
|
$x = $this->tainacan_entity_factory->create_entity(
|
||||||
|
'collection',
|
||||||
|
array(
|
||||||
|
'name' => 'teste',
|
||||||
|
'description' => 'adasdasdsa',
|
||||||
|
'default_order' => 'DESC',
|
||||||
|
'slug' => 'duplicated_slug',
|
||||||
|
'status' => 'publish'
|
||||||
|
),
|
||||||
|
true
|
||||||
|
);
|
||||||
|
|
||||||
|
$y = $this->tainacan_entity_factory->create_entity(
|
||||||
|
'collection',
|
||||||
|
array(
|
||||||
|
'name' => 'teste',
|
||||||
|
'description' => 'adasdasdsa',
|
||||||
|
'default_order' => 'DESC',
|
||||||
|
'slug' => 'duplicated_slug',
|
||||||
|
'status' => 'publish'
|
||||||
|
),
|
||||||
|
true
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertNotEquals($x->get_slug(), $y->get_slug());
|
||||||
|
|
||||||
|
// Create as draft and publish later
|
||||||
|
$x = $this->tainacan_entity_factory->create_entity(
|
||||||
|
'collection',
|
||||||
|
array(
|
||||||
|
'name' => 'teste',
|
||||||
|
'description' => 'adasdasdsa',
|
||||||
|
'default_order' => 'DESC',
|
||||||
|
'slug' => 'duplicated_slug',
|
||||||
|
),
|
||||||
|
true
|
||||||
|
);
|
||||||
|
|
||||||
|
$y = $this->tainacan_entity_factory->create_entity(
|
||||||
|
'collection',
|
||||||
|
array(
|
||||||
|
'name' => 'teste',
|
||||||
|
'description' => 'adasdasdsa',
|
||||||
|
'default_order' => 'DESC',
|
||||||
|
'slug' => 'duplicated_slug',
|
||||||
|
),
|
||||||
|
true
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertEquals($x->get_slug(), $y->get_slug());
|
||||||
|
|
||||||
|
global $Tainacan_Collections;
|
||||||
|
$x->set_status('publish');
|
||||||
|
$x->validate();
|
||||||
|
$x = $Tainacan_Collections->insert($x);
|
||||||
|
$y->set_status('private'); // or publish shoud behave the same
|
||||||
|
$y->validate();
|
||||||
|
$y = $Tainacan_Collections->insert($y);
|
||||||
|
|
||||||
|
$this->assertNotEquals($x->get_slug(), $y->get_slug());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
function test_item() {
|
function test_item() {
|
||||||
$x = $this->tainacan_entity_factory->create_entity(
|
$x = $this->tainacan_entity_factory->create_entity(
|
||||||
'collection',
|
'collection',
|
||||||
|
|
Loading…
Reference in New Issue