translationEntry.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. class Tests_POMO_TranslationEntry extends WP_UnitTestCase {
  3. function test_create_entry() {
  4. // no singular => empty object
  5. $entry = new Translation_Entry();
  6. $this->assertNull($entry->singular);
  7. $this->assertNull($entry->plural);
  8. $this->assertFalse($entry->is_plural);
  9. // args -> members
  10. $entry = new Translation_Entry(array(
  11. 'singular' => 'baba',
  12. 'plural' => 'babas',
  13. 'translations' => array('баба', 'баби'),
  14. 'references' => 'should be array here',
  15. 'flags' => 'baba',
  16. ));
  17. $this->assertEquals('baba', $entry->singular);
  18. $this->assertEquals('babas', $entry->plural);
  19. $this->assertTrue($entry->is_plural);
  20. $this->assertEquals(array('баба', 'баби'), $entry->translations);
  21. $this->assertEquals(array(), $entry->references);
  22. $this->assertEquals(array(), $entry->flags);
  23. }
  24. function test_key() {
  25. $entry_baba = new Translation_Entry(array('singular' => 'baba',));
  26. $entry_dyado = new Translation_Entry(array('singular' => 'dyado',));
  27. $entry_baba_ctxt = new Translation_Entry(array('singular' => 'baba', 'context' => 'x'));
  28. $entry_baba_plural = new Translation_Entry(array('singular' => 'baba', 'plural' => 'babas'));
  29. $this->assertEquals($entry_baba->key(), $entry_baba_plural->key());
  30. $this->assertNotEquals($entry_baba->key(), $entry_baba_ctxt->key());
  31. $this->assertNotEquals($entry_baba_plural->key(), $entry_baba_ctxt->key());
  32. $this->assertNotEquals($entry_baba->key(), $entry_dyado->key());
  33. }
  34. }