菜谱项目

AddressTest.php 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. namespace Faker\Test\Provider\it_CH;
  3. use Faker\Generator;
  4. use Faker\Provider\it_CH\Address;
  5. use Faker\Provider\it_CH\Person;
  6. class AddressTest extends \PHPUnit_Framework_TestCase
  7. {
  8. /**
  9. * @var Faker\Generator
  10. */
  11. private $faker;
  12. public function setUp()
  13. {
  14. $faker = new Generator();
  15. $faker->addProvider(new Address($faker));
  16. $faker->addProvider(new Person($faker));
  17. $this->faker = $faker;
  18. }
  19. /**
  20. * @test
  21. */
  22. public function canton ()
  23. {
  24. $canton = $this->faker->canton();
  25. $this->assertInternalType('array', $canton);
  26. $this->assertCount(1, $canton);
  27. foreach ($canton as $cantonShort => $cantonName){
  28. $this->assertInternalType('string', $cantonShort);
  29. $this->assertEquals(2, strlen($cantonShort));
  30. $this->assertInternalType('string', $cantonName);
  31. $this->assertGreaterThan(2, strlen($cantonName));
  32. }
  33. }
  34. /**
  35. * @test
  36. */
  37. public function cantonName ()
  38. {
  39. $cantonName = $this->faker->cantonName();
  40. $this->assertInternalType('string', $cantonName);
  41. $this->assertGreaterThan(2, strlen($cantonName));
  42. }
  43. /**
  44. * @test
  45. */
  46. public function cantonShort ()
  47. {
  48. $cantonShort = $this->faker->cantonShort();
  49. $this->assertInternalType('string', $cantonShort);
  50. $this->assertEquals(2, strlen($cantonShort));
  51. }
  52. /**
  53. * @test
  54. */
  55. public function address (){
  56. $address = $this->faker->address();
  57. $this->assertInternalType('string', $address);
  58. }
  59. }