function TMGMTCRUDTestCase::testJobItems in Translation Management Tool 7
Test crud operations of job items.
File
- tests/
tmgmt.crud.test, line 172
Class
- TMGMTCRUDTestCase
- Basic CRUD tests.
Code
function testJobItems() {
$job = $this
->createJob();
// Add some test items.
$item1 = $job
->addItem('test_source', 'type', 5);
$item2 = $job
->addItem('test_source', 'test_with_long_label', 4);
// Test single load callback.
$item = tmgmt_job_item_load($item1->tjiid);
$this
->assertEqual($item1->plugin, $item->plugin);
$this
->assertEqual($item1->item_type, $item->item_type);
$this
->assertEqual($item1->item_id, $item->item_id);
// Test multiple load callback.
$items = tmgmt_job_item_load_multiple(array(
$item1->tjiid,
$item2->tjiid,
));
$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);
// Test the second item label length - it must not exceed the
// TMGMT_JOB_LABEL_MAX_LENGTH.
$this
->assertTrue(TMGMT_JOB_LABEL_MAX_LENGTH >= strlen($items[$item2->tjiid]
->label()));
}