2017-11-13 23:23:13 +00:00
|
|
|
<?php
|
2017-11-15 18:50:11 +00:00
|
|
|
|
|
|
|
namespace Tainacan\Tests;
|
2018-04-10 17:47:32 +00:00
|
|
|
|
2018-04-10 19:24:33 +00:00
|
|
|
use Tainacan\Entities\Collection;
|
2017-11-24 21:15:41 +00:00
|
|
|
use Tainacan\Entities\Log;
|
2017-11-15 18:50:11 +00:00
|
|
|
|
2017-11-13 23:23:13 +00:00
|
|
|
/**
|
|
|
|
* Class TestCollections
|
|
|
|
*
|
|
|
|
* @package Test_Tainacan
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sample test case.
|
|
|
|
*/
|
2017-12-04 18:20:49 +00:00
|
|
|
class Logs extends TAINACAN_UnitTestCase {
|
2017-11-13 23:23:13 +00:00
|
|
|
|
|
|
|
|
2018-04-10 17:47:32 +00:00
|
|
|
/**
|
|
|
|
* Teste da insercao de um log simples apenas se criar o dado bruto
|
|
|
|
*/
|
|
|
|
function test_add() {
|
2018-04-11 14:26:46 +00:00
|
|
|
$Tainacan_Logs = \Tainacan\Repositories\Logs::get_instance();
|
2018-04-10 17:47:32 +00:00
|
|
|
|
2018-04-11 14:38:32 +00:00
|
|
|
$log = $this->tainacan_entity_factory->create_entity(
|
|
|
|
'log',
|
|
|
|
array(
|
|
|
|
'title' => 'blame someone',
|
|
|
|
'description' => 'someone did that'
|
|
|
|
),
|
|
|
|
true
|
|
|
|
);
|
|
|
|
|
|
|
|
$user_id = get_current_user_id();
|
|
|
|
$blog_id = get_current_blog_id();
|
|
|
|
|
|
|
|
//retorna a taxonomia
|
|
|
|
$test = $Tainacan_Logs->fetch( $log->get_id() );
|
|
|
|
|
2018-04-10 17:47:32 +00:00
|
|
|
$this->assertEquals( 'blame someone', $test->get_title() );
|
|
|
|
$this->assertEquals( 'someone did that', $test->get_description() );
|
|
|
|
$this->assertEquals( $user_id, $test->get_user_id() );
|
|
|
|
$this->assertEquals( $blog_id, $test->get_blog_id() );
|
|
|
|
}
|
|
|
|
|
|
|
|
public function test_log_diff() {
|
2018-04-11 14:26:46 +00:00
|
|
|
$Tainacan_Logs = \Tainacan\Repositories\Logs::get_instance();
|
|
|
|
$Tainacan_Filters = \Tainacan\Repositories\Filters::get_instance();
|
2018-04-10 17:47:32 +00:00
|
|
|
|
2018-04-11 14:38:32 +00:00
|
|
|
$filter = $this->tainacan_entity_factory->create_entity(
|
|
|
|
'filter',
|
|
|
|
array(
|
|
|
|
'name' => 'No name',
|
|
|
|
),
|
|
|
|
true
|
|
|
|
);
|
2018-04-10 17:47:32 +00:00
|
|
|
|
2018-04-11 14:38:32 +00:00
|
|
|
// Modify filter name
|
|
|
|
$filter->set_name( 'With name' );
|
2018-04-10 17:47:32 +00:00
|
|
|
|
2018-04-11 14:38:32 +00:00
|
|
|
$Tainacan_Filters->update( $filter );
|
2018-04-10 17:47:32 +00:00
|
|
|
|
2018-04-11 14:38:32 +00:00
|
|
|
$log = $Tainacan_Logs->fetch_last();
|
2018-04-10 17:47:32 +00:00
|
|
|
|
2018-04-17 19:21:54 +00:00
|
|
|
$diff = $log->get_log_diffs();
|
2018-04-10 17:47:32 +00:00
|
|
|
|
2018-04-11 14:38:32 +00:00
|
|
|
$this->assertEquals( 'With name', "{$diff['name']['new'][0]} {$diff['name']['new'][1]}" );
|
|
|
|
$this->assertEquals( 'No name', $diff['name']['old'] );
|
|
|
|
$this->assertEquals( 'With', $diff['name']['diff_with_index'][0] );
|
|
|
|
}
|
2017-11-13 23:23:13 +00:00
|
|
|
}
|