Skip to content

Commit

Permalink
Add tests for locale glossary without project glossary
Browse files Browse the repository at this point in the history
  • Loading branch information
ocean90 committed Feb 18, 2017
1 parent 0f0b32d commit d594305
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion tests/phpunit/testcases/tests_things/test_thing_glossary.php
Expand Up @@ -94,7 +94,7 @@ function test_get_entries() {
*/
function test_locale_glossary() {
$locale = $this->factory->locale->create();
$locale_set = $this->factory->translation_set->create( array( 'project_id' => 0, 'locale' => $locale->slug ));
$locale_set = $this->factory->translation_set->create( array( 'project_id' => 0, 'locale' => $locale->slug ) );
$locale_glossary = GP::$glossary->create_and_select( array( 'translation_set_id' => $locale_set->id ) );

$args = array(
Expand Down Expand Up @@ -144,6 +144,32 @@ function test_locale_glossary() {
$this->assertCount( 1, $entries );
$this->assertEquals( $test_entries[0]['translation'], $entries[0]->translation );
}

/**
* @ticket gh-435
*/
function test_locale_glossary_without_project_glossary() {
$locale = $this->factory->locale->create();
$locale_set = $this->factory->translation_set->create( array( 'project_id' => 0, 'locale' => $locale->slug ) );
$locale_glossary = GP::$glossary->create_and_select( array( 'translation_set_id' => $locale_set->id ) );

$set = $this->factory->translation_set->create_with_project( array(
'locale' => $locale_set->locale,
'slug' => $locale_set->slug,
) );

GP::$glossary_entry->create( array(
'term' => 'Term 2',
'part_of_speech' => 'noun',
'translation' => 'Translation 2',
'glossary_id' => $locale_glossary->id,
) );

$route = new Testable_GP_Route_Translation;
$extended_glossary = $route->testable_get_extended_glossary( $set, $set->project );
$this->assertInstanceOf( 'GP_Glossary', $extended_glossary );
$this->assertCount( 1, $extended_glossary->get_entries() );
}
}

/**
Expand Down

0 comments on commit d594305

Please sign in to comment.