getIntance TO get_instance

This commit is contained in:
andre2ar 2018-04-11 11:38:32 -03:00
parent 105465ee06
commit a7a3cef50b
1 changed files with 29 additions and 79 deletions

View File

@ -17,11 +17,6 @@ use Tainacan\Entities\Log;
class Logs extends TAINACAN_UnitTestCase {
/**
* Teste da insercao de um log simples apenas se criar o dado bruto
*/
function test_add() {
$Tainacan_Logs = \Tainacan\Repositories\Logs::get_instance();
/**
* Teste da insercao de um log simples apenas se criar o dado bruto
*/
@ -29,64 +24,21 @@ class Logs extends TAINACAN_UnitTestCase {
$Tainacan_Logs = \Tainacan\Repositories\Logs::get_instance();
$Tainacan_Collections = \Tainacan\Repositories\Collections::get_instance();
$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();
$log = $this->tainacan_entity_factory->create_entity(
'log',
array(
'title' => 'blame someone',
'description' => 'someone did that'
),
true
);
//retorna a taxonomia
$test = $Tainacan_Logs->fetch($log->get_id());
$user_id = get_current_user_id();
$blog_id = get_current_blog_id();
//retorna a taxonomia
$test = $Tainacan_Logs->fetch( $log->get_id() );
$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() );
$value = $this->tainacan_entity_factory->create_entity(
'collection',
array(
'name' => 'testeLogs',
'description' => 'adasdasdsa123',
'default_order' => 'DESC'
),
true
);
$Tainacan_Collections = \Tainacan\Repositories\Collections::get_instance();
$value->set_name('new_testeLogs');
$value->validate();
$new_value = $Tainacan_Collections->insert($value);
$create_log = Log::create('teste create', 'testing a log creation function', $new_value, $value);
$this->assertEquals( 'teste create', $create_log->get_title() );
$this->assertEquals( 'testing a log creation function', $create_log->get_description() );
$this->assertEquals( $new_value, $create_log->get_value() );
$this->assertEquals( $value, $create_log->get_old_value() );
$testDB = $Tainacan_Logs->fetch($create_log->get_id());
$this->assertEquals( 'teste create', $testDB->get_title() );
$this->assertEquals( 'testing a log creation function', $testDB->get_description() );
$this->assertEquals( $new_value, $testDB->get_value() );
$this->assertEquals( $value, $testDB->get_old_value() );
$last_log = $Tainacan_Logs->fetch_last();
$this->assertTrue(is_object($last_log));
$collection = $last_log->get_value();
$this->assertEquals($collection->get_name(), 'new_testeLogs');
$this->assertEquals($collection->get_description(), 'adasdasdsa123');
$this->assertEquals($collection->get_default_order(), 'DESC');
}
$this->assertEquals( 'blame someone', $test->get_title() );
$this->assertEquals( 'someone did that', $test->get_description() );
$this->assertEquals( $user_id, $test->get_user_id() );
@ -131,31 +83,29 @@ class Logs extends TAINACAN_UnitTestCase {
$this->assertEquals( 'DESC', $collection->get_default_order() );
}
public function test_log_diff(){
$Tainacan_Logs = \Tainacan\Repositories\Logs::get_instance();
$Tainacan_Filters = \Tainacan\Repositories\Filters::get_instance();
public function test_log_diff() {
$Tainacan_Logs = \Tainacan\Repositories\Logs::get_instance();
$Tainacan_Filters = \Tainacan\Repositories\Filters::get_instance();
$filter = $this->tainacan_entity_factory->create_entity(
'filter',
array(
'name' => 'No name'
),
true
);
$filter = $this->tainacan_entity_factory->create_entity(
'filter',
array(
'name' => 'No name',
),
true
);
// Modify filter name
$filter->set_name('With name');
// Modify filter name
$filter->set_name( 'With name' );
$Tainacan_Filters->update($filter);
$Tainacan_Filters->update( $filter );
$log = $Tainacan_Logs->fetch_last();
$log = $Tainacan_Logs->fetch_last();
$diff = $log->diff();
$diff = $log->diff();
$this->assertEquals('With name', $diff['name']['new']);
$this->assertEquals('No name', $diff['name']['old']);
}
$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] );
}
}