1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?php
namespace Faker\Test\Provider\uk_UA;
use Faker\Generator;
use Faker\Provider\uk_UA\Address;
class AddressTest extends \PHPUnit_Framework_TestCase
{
/**
* @var Generator
*/
private $faker;
public function setUp()
{
$faker = new Generator();
$faker->addProvider(new Address($faker));
$this->faker = $faker;
}
public function testPostCodeIsValid()
{
$main = '[0-9]{5}';
$pattern = "/^($main)|($main-[0-9]{3})+$/";
$postcode = $this->faker->postcode;
$this->assertRegExp($pattern, $postcode, 'Post code ' . $postcode . ' is wrong!');
}
public function testEmptySuffixes()
{
$this->assertEmpty($this->faker->citySuffix, 'City suffix should be empty!');
$this->assertEmpty($this->faker->streetSuffix, 'Street suffix should be empty!');
}
public function testStreetCyrOnly()
{
$pattern = "/[0-9А-ЩЯІЇЄЮа-щяіїєюьIVXCM][0-9А-ЩЯІЇЄЮа-щяіїєюь \'-.]*[А-Яа-я.]/u";
$streetName = $this->faker->streetName;
$this->assertSame(
preg_match($pattern, $streetName),
1,
'Street name ' . $streetName . ' is wrong!'
);
}
public function testCityNameCyrOnly()
{
$pattern = "/[А-ЩЯІЇЄЮа-щяіїєюь][0-9А-ЩЯІЇЄЮа-щяіїєюь \'-]*[А-Яа-я]/u";
$city = $this->faker->city;
$this->assertSame(
preg_match($pattern, $city),
1,
'City name ' . $city . ' is wrong!'
);
}
public function testRegionNameCyrOnly()
{
$pattern = "/[А-ЩЯІЇЄЮ][А-ЩЯІЇЄЮа-щяіїєюь]*а$/u";
$regionName = $this->faker->region;
$this->assertSame(
preg_match($pattern, $regionName),
1,
'Region name ' . $regionName . ' is wrong!'
);
}
public function testCountryCyrOnly()
{
$pattern = "/[А-ЩЯІЇЄЮа-щяіїєюьIVXCM][А-ЩЯІЇЄЮа-щяіїєюь \'-]*[А-Яа-я.]/u";
$country = $this->faker->country;
$this->assertSame(
preg_match($pattern, $country),
1,
'Country name ' . $country . ' is wrong!'
);
}
}