Skip to content

Commit

Permalink
Corrections after unit test execution
Browse files Browse the repository at this point in the history
  • Loading branch information
defro committed Jan 6, 2017
1 parent ba778a2 commit bf3ff8a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 14 deletions.
4 changes: 3 additions & 1 deletion src/config/gettext.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<?php
if ( ! defined('PHPUNIT_TESTING')) {
// @codeCoverageIgnoreStart
if (!defined('PHPUNIT_TESTING')) {
defined('BASEPATH') || exit('No direct script access allowed');
}
// @codeCoverageIgnoreEnd

// Gettext catalog codeset
$config['gettext_catalog_codeset'] = 'UTF-8';
Expand Down
13 changes: 7 additions & 6 deletions src/libraries/Gettext.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ static public function init(array $config)

log_message(
(is_string($IsBindTextDomainCodeset) ? 'info' : 'error'),
'Gettext Library -> Try to bind textdomain_codeset: ' .
'Gettext Library -> Try to bind text domain code set: ' .
$config['gettext_catalog_codeset']
);

Expand All @@ -70,7 +70,7 @@ static public function init(array $config)

log_message(
(is_string($IsBindTextDomain) ? 'info' : 'error'),
'Gettext Library -> Try to bind text domain: ' .
'Gettext Library -> Try to bind text domain directory: ' .
APPPATH . $config['gettext_locale_dir']
);

Expand All @@ -81,7 +81,7 @@ static public function init(array $config)

log_message(
(is_string($IsSetTextDomain) ? 'info' : 'error'),
'Gettext Library -> Try to set text_domain: ' .
'Gettext Library -> Try to set text domain: ' .
$config['gettext_text_domain']
);

Expand All @@ -93,7 +93,7 @@ static public function init(array $config)

log_message(
(is_string($IsSetLocale) ? 'info' : 'error'),
'Gettext Library -> Try to set gettext locale: ' .
'Gettext Library -> Try to set locale: ' .
(is_array($config['gettext_locale']) ?
print_r($config['gettext_locale'], TRUE) :
$config['gettext_locale']
Expand All @@ -105,7 +105,7 @@ static public function init(array $config)

log_message(
($IsPutEnv === TRUE ? 'info' : 'error'),
'Gettext Library -> Try to set Environment LANGUAGE: ' .
'Gettext Library -> Try to set environment language: ' .
(is_array($config['gettext_locale']) ?
$config['gettext_locale'][0] :
$config['gettext_locale']
Expand All @@ -128,4 +128,5 @@ static public function init(array $config)
}
}

/* End of file Gettext.php */
/* End of file Gettext.php */
/* Location: ./libraries/config/gettext.php */
22 changes: 15 additions & 7 deletions tests/GettextTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,39 +13,45 @@ class GettextTest extends PHPUnit_Framework_TestCase

private function _regex($expression, $successful = TRUE)
{
$state = ($successful ? 'Successful' : 'FAILED');
$regex = '/(info|).*(' . $expression . ').*(' . $state . ')/';
$log = ($successful ? 'info' : 'debug');
$regex = '/(' . $log . '|).*(' . $expression . ')/';

return ($regex);
}

public function testCatalogCodeset()
{
$this->expectOutputRegex($this->_regex('catalog_codeset'));
$this->expectOutputRegex($this->_regex('bind text domain code set'));
$this->_library();
}

public function testLocaleDir()
{
$this->expectOutputRegex($this->_regex('text domain \(locale dir\)'));
$this->expectOutputRegex($this->_regex('bind text domain directory'));
$this->_library();
}

public function testTextDomain()
{
$this->expectOutputRegex($this->_regex('text_domain'));
$this->expectOutputRegex($this->_regex('set text domain'));
$this->_library();
}

public function testLocale()
{
$this->expectOutputRegex($this->_regex('locale'));
$this->expectOutputRegex($this->_regex('set locale'));
$this->_library();
}

public function testEnvironmentLanguage()
{
$this->expectOutputRegex($this->_regex('Environment LANGUAGE'));
$this->expectOutputRegex($this->_regex('set environment language'));
$this->_library();
}

public function testFileExists()
{
$this->expectOutputRegex($this->_regex('check MO file exists'));
$this->_library();
}

Expand All @@ -60,6 +66,8 @@ private function _library()
'gettext_locale' => $CI->config->item('gettext_locale')
);
*/

// Load default config array
require(realpath(dirname(__FILE__) . '/../') . '/src/config/gettext.php');

Gettext::init($config);
Expand Down

0 comments on commit bf3ff8a

Please sign in to comment.