Initial Commit
This commit is contained in:
103
tests/phpunit/Thelia/Tests/Api/CurrencyControllerTest.php
Normal file
103
tests/phpunit/Thelia/Tests/Api/CurrencyControllerTest.php
Normal file
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* This file is part of the Thelia package. */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : dev@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* For the full copyright and license information, please view the LICENSE.txt */
|
||||
/* file that was distributed with this source code. */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Tests\Api;
|
||||
|
||||
use Thelia\Tests\ApiTestCase;
|
||||
|
||||
/**
|
||||
* Class CurrencyControllerTest
|
||||
* @package Thelia\Tests\Api
|
||||
* @author Benjamin Perche <bperche@openstudio.fr>
|
||||
*/
|
||||
class CurrencyControllerTest extends ApiTestCase
|
||||
{
|
||||
public function testListAction()
|
||||
{
|
||||
$client = static::createClient();
|
||||
|
||||
$client->request(
|
||||
'GET',
|
||||
'/api/currencies?sign='.$this->getSignParameter(''),
|
||||
[],
|
||||
[],
|
||||
$this->getServerParameters()
|
||||
);
|
||||
|
||||
$this->assertEquals(200, $client->getResponse()->getStatusCode(), 'Http status code must be 200');
|
||||
$content = json_decode($client->getResponse()->getContent(), true);
|
||||
|
||||
$this->assertGreaterThan(0, count($content), 'The request must return at least one result');
|
||||
}
|
||||
|
||||
public function testListActionWithLocale()
|
||||
{
|
||||
$client = static::createClient();
|
||||
|
||||
$client->request(
|
||||
'GET',
|
||||
'/api/currencies?lang=fr_FR&sign='.$this->getSignParameter(''),
|
||||
[],
|
||||
[],
|
||||
$this->getServerParameters()
|
||||
);
|
||||
|
||||
$this->assertEquals(200, $client->getResponse()->getStatusCode(), 'Http status code must be 200');
|
||||
$content = json_decode($client->getResponse()->getContent(), true);
|
||||
|
||||
$this->assertGreaterThan(0, count($content), 'The request must return at least one result');
|
||||
|
||||
$firstResult = $content[0];
|
||||
|
||||
$this->assertEquals('fr_FR', $firstResult['LOCALE'], 'the returned locale must be fr_FR');
|
||||
}
|
||||
|
||||
public function testGetAction()
|
||||
{
|
||||
$client = static::createClient();
|
||||
|
||||
$client->request(
|
||||
'GET',
|
||||
'/api/currencies/1?sign='.$this->getSignParameter(''),
|
||||
[],
|
||||
[],
|
||||
$this->getServerParameters()
|
||||
);
|
||||
|
||||
$this->assertEquals(200, $client->getResponse()->getStatusCode(), 'Http status code must be 200');
|
||||
$content = json_decode($client->getResponse()->getContent(), true);
|
||||
|
||||
$this->assertCount(1, $content, 'The request must return one result');
|
||||
}
|
||||
|
||||
public function testGetActionWithLocale()
|
||||
{
|
||||
$client = static::createClient();
|
||||
|
||||
$client->request(
|
||||
'GET',
|
||||
'/api/currencies/1?lang=fr_FR&sign='.$this->getSignParameter(''),
|
||||
[],
|
||||
[],
|
||||
$this->getServerParameters()
|
||||
);
|
||||
|
||||
$this->assertEquals(200, $client->getResponse()->getStatusCode(), 'Http status code must be 200');
|
||||
$content = json_decode($client->getResponse()->getContent(), true);
|
||||
|
||||
$this->assertCount(1, $content, 'The request must return one result');
|
||||
|
||||
$firstResult = $content[0];
|
||||
|
||||
$this->assertEquals('fr_FR', $firstResult['LOCALE'], 'the returned locale must be fr_FR');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user