tmgmt_entity.pathauto.test 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. /**
  3. * Tests integration with pathauto.
  4. */
  5. class TMGMTEntitySourcePathAutoTestCase extends TMGMTEntityTestCaseUtility {
  6. static function getInfo() {
  7. return array(
  8. 'name' => 'Entity Source Pathauto tests',
  9. 'description' => 'Verifies that the correct aliases are generated for entity transations',
  10. 'group' => 'Translation Management',
  11. 'dependencies' => array('entity_translation', 'pathauto'),
  12. );
  13. }
  14. function setUp() {
  15. parent::setUp(array('tmgmt_entity', 'entity_translation', 'pathauto'));
  16. $this->loginAsAdmin();
  17. $this->createNodeType('article', 'Article', ENTITY_TRANSLATION_ENABLED);
  18. }
  19. /**
  20. * Tests that pathauto aliases are correctly created.
  21. */
  22. function testAliasCreation() {
  23. $this->setEnvironment('de');
  24. // Create a translation job.
  25. $job = $this->createJob();
  26. $job->translator = $this->default_translator->name;
  27. $job->settings = array();
  28. $job->save();
  29. // Create a node.
  30. $node = $this->createNode('article');
  31. // Create a job item for this node and add it to the job.
  32. $job->addItem('entity', 'node', $node->nid);
  33. // Translate the job.
  34. $job->requestTranslation();
  35. // Check the translated job items.
  36. foreach ($job->getItems() as $item) {
  37. $item->acceptTranslation();
  38. }
  39. // Make sure that the correct url aliases were created.
  40. $aliases = db_query('SELECT * FROM {url_alias} where source = :source', array(':source' => 'node/' . $node->nid))->fetchAllAssoc('language');
  41. $this->assertEqual(2, count($aliases));
  42. $this->assertTrue(isset($aliases['en']), 'English alias created.');
  43. $this->assertTrue(isset($aliases['de']), 'German alias created.');
  44. }
  45. }