Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
trasher committed Mar 21, 2023
1 parent ced1613 commit 8322fe5
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 19 deletions.
4 changes: 2 additions & 2 deletions phpunit/Galette/Core/tests/units/I18n.php
Expand Up @@ -90,7 +90,7 @@ public function testAutoLang()
{
$this->i18n = new \Galette\Core\I18n();

$this->assertSame('en_US', $this->i18n->getID());
$this->assertSame(\Galette\Core\I18n::DEFAULT_LANG, $this->i18n->getID());

//simulate fr from browser
$_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'fr_BE';
Expand All @@ -108,7 +108,7 @@ public function testAutoLang()
$_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'un_KN';
$this->i18n = new \Galette\Core\I18n();

$this->assertSame('en_US', $this->i18n->getID());
$this->assertSame(\Galette\Core\I18n::DEFAULT_LANG, $this->i18n->getID());
}

/**
Expand Down
37 changes: 21 additions & 16 deletions tests/Galette/Core/tests/units/I18n.php
Expand Up @@ -94,8 +94,7 @@ public function testAutoLang()
{
$this->i18n = new \Galette\Core\I18n();

$this->variable($this->i18n->getID())
->isIdenticalTo('fr_FR');
$this->variable($this->i18n->getID())->isIdenticalTo(\Galette\Core\I18n::DEFAULT_LANG);

//simulate fr from browser
$_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'fr_BE';
Expand All @@ -108,8 +107,7 @@ public function testAutoLang()
$_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'en_GB';
$this->i18n = new \Galette\Core\I18n();

$this->variable($this->i18n->getID())
->isIdenticalTo('en_US');
$this->variable($this->i18n->getID())->isIdenticalTo('en_US');

//simulate unknown lang from browser
$_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'un_KN';
Expand Down Expand Up @@ -158,9 +156,10 @@ public function testGetArrayList()
public function testGetNameFromid()
{
$lang = $this->i18n->getNameFromId('en_US');
$this->variable($lang)->isIdenticalTo('English');

$this->variable($lang)
->isIdenticalTo('English');
$lang = $this->i18n->getNameFromId('fr_FR');
$this->variable($lang)->isIdenticalTo('Français');
}

/**
Expand All @@ -175,14 +174,21 @@ public function testGetLangInfos()
$name = $this->i18n->getName();
$abbrev = $this->i18n->getAbbrev();

$this->variable($id)
->isIdenticalTo('fr_FR');
$this->variable($longid)
->isIdenticalTo('fr_FR.utf8');
$this->variable($name)
->isIdenticalTo('Français');
$this->variable($abbrev)
->isIdenticalTo('fr');
$this->variable($id)->isIdenticalTo('en_US');
$this->variable($longid)->isIdenticalTo('en_US');
$this->variable($name)->isIdenticalTo('English');
$this->variable($abbrev)->isIdenticalTo('en');

$this->i18n->changeLanguage('fr_FR');
$id = $this->i18n->getID();
$longid = $this->i18n->getLongID();
$name = $this->i18n->getName();
$abbrev = $this->i18n->getAbbrev();

$this->variable($id)->isIdenticalTo('fr_FR');
$this->variable($longid)->isIdenticalTo('fr_FR.utf8');
$this->variable($name)->isIdenticalTo('Français');
$this->variable($abbrev)->isIdenticalTo('fr');
}

/**
Expand All @@ -195,8 +201,7 @@ public function testChangeUnknownLanguage()
$this->i18n->changeLanguage('un_KN');
$id = $this->i18n->getID();

$this->variable($id)
->isIdenticalTo('fr_FR');
$this->variable($id)->isIdenticalTo(\Galette\Core\I18n::DEFAULT_LANG);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/Galette/IO/tests/units/News.php
Expand Up @@ -93,7 +93,7 @@ public function testLoadNews()
public function testCacheNews()
{
//will use default lang to build RSS URL
$file = GALETTE_CACHE_DIR . md5('https://galette.eu/site/fr/feed.xml') . '.cache';
$file = GALETTE_CACHE_DIR . md5('https://galette.eu/site/feed.xml') . '.cache';

//ensure file does not exists
$this->boolean(file_exists($file))->isFalse;
Expand Down

0 comments on commit 8322fe5

Please sign in to comment.