AddressTest.php 1.6 KB

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