SproutCMS

This is the code documentation for the SproutCMS project

source of /sprout/tests/LocaleInfoTest.php

  1. <?php
  2. /*
  3.  * Copyright (C) 2017 Karmabunny Pty Ltd.
  4.  *
  5.  * This file is a part of SproutCMS.
  6.  *
  7.  * SproutCMS is free software: you can redistribute it and/or modify it under the terms
  8.  * of the GNU General Public License as published by the Free Software Foundation, either
  9.  * version 2 of the License, or (at your option) any later version.
  10.  *
  11.  * For more information, visit <http://getsproutcms.com>.
  12.  */
  13.  
  14. use Sprout\Helpers\Locales\LocaleInfo;
  15.  
  16.  
  17. class LocaleInfoTest extends PHPUnit_Framework_TestCase
  18. {
  19.  
  20. public function dataGetStateName()
  21. {
  22. return [
  23. ['AUS', 'SA', 'South Australia'], // Abbreviations
  24. ['AND', 'Canillo', 'Canillo'], // Numeric
  25. ['JPN', 'Aomori-ken', 'Aomori'], // Optgroups
  26.  
  27. // No states/provinces; always null
  28. ['VAT', '', null],
  29. ['VAT', null, null],
  30. ['VAT', 1, null],
  31. ['VAT', 'AAA', null],
  32. ];
  33. }
  34.  
  35. /**
  36.   * @dataProvider dataGetStateName
  37.   **/
  38. public function testGetStateName($country, $state, $expected)
  39. {
  40. $locale = LocaleInfo::get($country);
  41. $this->assertEquals($expected, $locale->getStateName($state));
  42. }
  43.  
  44. }
  45.