Skip to content

Commit

Permalink
Started working on Locale (interface, entity, test)
Browse files Browse the repository at this point in the history
  • Loading branch information
LittleBigDev committed Jan 19, 2018
1 parent 4b3a8f4 commit ed1d40b
Show file tree
Hide file tree
Showing 3 changed files with 163 additions and 0 deletions.
72 changes: 72 additions & 0 deletions src/Core/Localization/Locale.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?php
/**
* 2007-2018 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <[email protected]>
* @copyright 2007-2018 PrestaShop SA
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/

namespace PrestaShop\PrestaShop\Core\Localization;

use PrestaShop\PrestaShop\Core\Localization\Currency\CurrencyCollection;
use PrestaShop\PrestaShop\Core\Localization\Specification\Number as NumberSpecification;
use PrestaShop\PrestaShop\Core\Localization\Specification\Price as PriceSpecification;

class Locale implements LocaleInterface
{
/**
* @var NumberSpecification
*/
protected $numberSpecification;

/**
* @var CurrencyCollection
*/
protected $currencies;

/**
* Get price specification for a given currency
*
* @param string $currencyCode
* The currency's ISO 4217 code
*
* @return PriceSpecification
* A Price specification
*/
protected function getPriceSpecification($currencyCode)
{
$currency = $this->currencies->get($currencyCode);

// $priceSpecification = new Price(
// $positivePattern,
// $negativePattern,
// $symbols,
// $maxFractionDigits,
// $minFractionDigits,
// $groupingUsed,
// $primaryGroupSize,
// $secondaryGroupSize,
// $currencyDisplay,
// $currency->getSymbol($this->code),
// $currency->getIsoCode()
// );
}
}
37 changes: 37 additions & 0 deletions src/Core/Localization/LocaleInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php
/**
* 2007-2018 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <[email protected]>
* @copyright 2007-2018 PrestaShop SA
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/

namespace PrestaShop\PrestaShop\Core\Localization;

/**
* Locale entity interface
*
* Describes the behavior of locale classes
*/
interface LocaleInterface
{

}
54 changes: 54 additions & 0 deletions tests/Unit/Core/Localization/LocaleTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php
/**
* 2007-2018 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <[email protected]>
* @copyright 2007-2018 PrestaShop SA
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/

namespace Tests\Unit\Core\Localization;

use PHPUnit\Framework\TestCase;
use PrestaShop\PrestaShop\Core\Localization\Locale;

class LocaleTest extends TestCase
{
protected $cldrLocale;

/**
* @inheritDoc
*/
protected function setUp()
{
// $this->locale was already taken by TestCase
$this->cldrLocale = new Locale();
}

public function testFormatNumber($number)
{
$this->markTestIncomplete('This test is not implemented yet');
}

public function testFormatPrice($number, $currencyCode)
{
$this->markTestIncomplete('This test is not implemented yet');
}
}

0 comments on commit ed1d40b

Please sign in to comment.