tainacan/tests/test-sample.php

72 lines
1.7 KiB
PHP
Raw Normal View History

<?php
/**
* Class TestCollections
*
* @package Test_Tainacan
*/
/**
* Sample test case.
*/
class TestCollections extends WP_UnitTestCase {
/**
* A single example test.
*/
function test_add() {
$x = new TainacanCollection();
$x->set_name('teste');
$x->set_description('adasdasdsa');
$x->set_itens_per_page(23);
global $TainacanCollections;
2017-11-12 23:14:47 +00:00
$col = $TainacanCollections->insert($x);
//
2017-11-12 23:14:47 +00:00
$test = $TainacanCollections->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 TainacanCollection();
$x->set_name('teste');
$x->set_description('adasdasdsa');
$x->set_itens_per_page(23);
global $TainacanCollections;
2017-11-12 23:14:47 +00:00
$col = $TainacanCollections->insert($x);
2017-11-09 12:44:52 +00:00
2017-11-12 23:14:47 +00:00
$collection = $TainacanCollections->get_collection_by_id($col->get_id());
2017-11-09 12:44:52 +00:00
$i = new TainacanItem();
$i->set_title('item teste');
$i->set_description('adasdasdsa');
$i->set_collection($collection);
global $TainacanItems;
2017-11-12 23:14:47 +00:00
$item = $TainacanItems->insert($i);
2017-11-09 12:44:52 +00:00
2017-11-12 23:14:47 +00:00
$item = $TainacanItems->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
}
}