예제 #1
0
 /**
  * Test...
  *
  * @covers Joomla\Language\Language::_
  *
  * @return void
  */
 public function test_()
 {
     $string1 = 'delete';
     $string2 = "delete's";
     $this->assertEquals('delete', $this->object->_($string1, false), 'Line: ' . __LINE__ . ' Exact case should match when javascript safe is false ');
     $this->assertNotEquals('Delete', $this->object->_($string1, false), 'Line: ' . __LINE__ . ' Should be case sensitive when javascript safe is false');
     $this->assertEquals('delete', $this->object->_($string1, true), 'Line: ' . __LINE__ . ' Exact case match should work when javascript safe is true');
     $this->assertNotEquals('Delete', $this->object->_($string1, true), 'Line: ' . __LINE__ . ' Should be case sensitive when javascript safe is true');
     $this->assertEquals('delete\'s', $this->object->_($string2, false), 'Line: ' . __LINE__ . ' Exact case should match when javascript safe is false ');
     $this->assertNotEquals('Delete\'s', $this->object->_($string2, false), 'Line: ' . __LINE__ . ' Should be case sensitive when javascript safe is false');
     $this->assertEquals("delete\\'s", $this->object->_($string2, true), 'Line: ' . __LINE__ . ' Exact case should match when javascript safe is true, also it calls addslashes (\' => \\\') ');
     $this->assertNotEquals("Delete\\'s", $this->object->_($string2, true), 'Line: ' . __LINE__ . ' Should be case sensitive when javascript safe is true,, also it calls addslashes (\' => \\\') ');
 }
 /**
  * Tests the _ method with strings loaded and debug enabled
  *
  * @covers  Joomla\Language\Language::_
  *
  * @return  void
  *
  * @since   1.1.2
  */
 public function test_WithLoadedStringsAndDebug()
 {
     // Loading some strings.
     TestHelper::setValue($this->object, 'strings', array('DEL' => 'Delete'));
     $this->assertEquals("Delete", $this->object->_('del', true));
     $this->assertEquals("Delete", $this->object->_('DEL', true));
     // Debug true tests
     TestHelper::setValue($this->object, 'debug', true);
     $this->assertArrayNotHasKey('DEL', TestHelper::getValue($this->object, 'used'));
     $this->assertEquals("**Delete**", $this->object->_('del', true));
     $this->assertArrayHasKey('DEL', TestHelper::getValue($this->object, 'used'));
     $this->assertArrayNotHasKey('DELET\\ED', TestHelper::getValue($this->object, 'orphans'));
     $this->assertEquals("??Delet\\\\ed??", $this->object->_('Delet\\ed', true));
     $this->assertArrayHasKey('DELET\\ED', TestHelper::getValue($this->object, 'orphans'));
 }