-
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from openfoodfacts/explicit_geography
feat: Explicit geography
- Loading branch information
Showing
2 changed files
with
36 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
namespace OpenFoodFacts\Laravel\Tests; | ||
|
||
use Illuminate\Support\Facades\Config; | ||
use OpenFoodFacts\Laravel\Facades\OpenFoodFacts as OpenFoodFactsFacade; | ||
use OpenFoodFacts\Laravel\OpenFoodFacts; | ||
|
||
class GeographyTest extends Base\FacadeTestCase | ||
{ | ||
/** @test */ | ||
public function it_returns_different_content_based_on_geography_parameter() | ||
{ | ||
$barcode = '8714200216964'; | ||
|
||
$instanceWorld = app()->make(OpenFoodFacts::class); | ||
$product_default_content = $instanceWorld->barcode($barcode); | ||
|
||
$instanceNL = app()->make(OpenFoodFacts::class, ['geography' => 'nl']); | ||
$product_dutch_content = $instanceNL->barcode($barcode); | ||
|
||
$this->assertEquals($product_default_content['_id'], $product_dutch_content['_id']); | ||
$this->assertNotEquals($product_default_content, $product_dutch_content); | ||
} | ||
|
||
/** @test */ | ||
public function it_returns_geo_specific_content_through_config_setting() | ||
{ | ||
Config::set('openfoodfacts.geography', 'nl'); | ||
$product_dutch_content = OpenFoodFactsFacade::barcode('8714200216964'); | ||
|
||
$this->assertStringContainsString('front_nl.', $product_dutch_content['image_url']); | ||
} | ||
} |