tainacan/tests/test-collections.php

91 lines
2.2 KiB
PHP
Raw Normal View History

<?php
/**
* Class TestCollections
*
* @package Test_Tainacan
*/
/**
* Sample test case.
*/
class Test_Collections extends WP_UnitTestCase {
/**
* A single example test.
*/
function test_add() {
$x = new Tainacan_Collection();
$x->set_name('teste');
$x->set_description('adasdasdsa');
$x->set_itens_per_page(23);
global $Tainacan_Collections;
$col = $Tainacan_Collections->insert($x);
//
$test = $Tainacan_Collections->get_collection_by_id($col->get_id());
$this->assertEquals($test->get_name(), 'teste');
$this->assertEquals($test->get_description(), 'adasdasdsa');
$this->assertEquals($test->get_itens_per_page(), 23);
2017-11-10 16:45:40 +00:00
}
2017-11-09 12:44:52 +00:00
function test_item() {
$x = new Tainacan_Collection();
2017-11-09 12:44:52 +00:00
$x->set_name('teste');
$x->set_description('adasdasdsa');
$x->set_itens_per_page(23);
global $Tainacan_Collections;
$col = $Tainacan_Collections->insert($x);
2017-11-09 12:44:52 +00:00
$collection = $Tainacan_Collections->get_collection_by_id($col->get_id());
2017-11-09 12:44:52 +00:00
$i = new Tainacan_Item();
2017-11-09 12:44:52 +00:00
$i->set_title('item teste');
$i->set_description('adasdasdsa');
$i->set_collection($collection);
global $Tainacan_Items;
$item = $Tainacan_Items->insert($i);
2017-11-09 12:44:52 +00:00
$item = $Tainacan_Items->get_item_by_id($item->get_id());
2017-11-09 12:44:52 +00:00
$this->assertEquals($item->get_title(), 'item teste');
$this->assertEquals($item->get_description(), 'adasdasdsa');
2017-11-12 23:14:47 +00:00
$this->assertEquals($item->get_collection_id(), $collection->get_id());
2017-11-09 12:44:52 +00:00
2017-11-15 02:04:40 +00:00
}
function test_validation() {
$x = new Tainacan_Collection();
$x->set_name('teste');
$x->set_description('adasdasdsa');
$x->set_itens_per_page('blah');
$this->assertFalse($x->validate());
$this->assertTrue(sizeof($x->get_errors()) > 0);
$x->set_itens_per_page(15);
$this->assertTrue($x->validate());
$this->assertTrue(empty($x->get_errors()));
2017-11-09 12:44:52 +00:00
}
}