function TMGMTCRUDTestCase::testJobs in Translation Management Tool 7
Test crud operations of jobs.
File
- tests/
tmgmt.crud.test, line 51
Class
- TMGMTCRUDTestCase
- Basic CRUD tests.
Code
function testJobs() {
$job = $this
->createJob();
$loaded_job = tmgmt_job_load($job->tjid);
$this
->assertEqual($job->source_language, $loaded_job->source_language);
$this
->assertEqual($job->target_language, $loaded_job->target_language);
// Assert that the created and changed information has been set to the
// default value.
$this
->assertTrue($loaded_job->created > 0);
$this
->assertTrue($loaded_job->changed > 0);
$this
->assertEqual(0, $loaded_job->state);
// Update the settings.
$job->reference = 7;
$this
->assertEqual(SAVED_UPDATED, $job
->save());
$loaded_job = tmgmt_job_load($job->tjid);
$this
->assertEqual($job->reference, $loaded_job->reference);
// Test the job items.
$item1 = $job
->addItem('test_source', 'type', 5);
$item2 = $job
->addItem('test_source', 'type', 4);
// Load and compare the items.
$items = $job
->getItems();
$this
->assertEqual(2, count($items));
$this
->assertEqual($item1->plugin, $items[$item1->tjiid]->plugin);
$this
->assertEqual($item1->item_type, $items[$item1->tjiid]->item_type);
$this
->assertEqual($item1->item_id, $items[$item1->tjiid]->item_id);
$this
->assertEqual($item2->plugin, $items[$item2->tjiid]->plugin);
$this
->assertEqual($item2->item_type, $items[$item2->tjiid]->item_type);
$this
->assertEqual($item2->item_id, $items[$item2->tjiid]->item_id);
// Delete the job and make sure it is gone.
$job
->delete();
$this
->assertFalse(tmgmt_job_load($job->tjid));
}