├── .gitignore
├── .travis.yml
├── LICENSE
├── README.md
├── composer.json
├── objects.php
├── phpunit.xml
├── src
├── Faker.php
├── Generator.php
└── helpers.php
└── tests
└── FakerTest.php
/.gitignore:
--------------------------------------------------------------------------------
1 | /.idea
2 | vendor
3 | composer.lock
4 |
5 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: php
2 | php:
3 | - 5.6
4 | - 7.0
5 | - 7.1
6 | - 7.2
7 | - hhvm
8 |
9 | script:
10 | - composer install
11 | - ./vendor/bin/phpunit
12 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2016 Alireza Josheghani
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | [](https://travis-ci.org/iamalirezaj/faker)
2 | [](https://packagist.org/packages/josh/faker)
3 | [](https://packagist.org/packages/josh/faker)
4 | [](//packagist.org/packages/josh/faker)
5 | [](https://packagist.org/packages/josh/faker)
6 | [](https://scrutinizer-ci.com/g/iamalirezaj/faker)
7 | [](https://saythanks.io/to/iamalirezaj)
8 | # Josh faker component
9 | A persian faker library for php
10 |
11 | ## Requirement
12 | * php 5.6 >=
13 |
14 | ## Install with composer
15 | You can install this package throw the [Composer](http://getcomposer.org) by running:
16 | ```
17 | composer require josh/faker
18 | ```
19 |
20 | ## Usage
21 | You can access to faker objects by according blew following table:
22 |
23 | ```php
24 | // use the faker namespace
25 |
26 | use Josh\Faker\Faker;
27 | ```
28 |
29 | | Objects | Descriptions |
30 | | --- | --- |
31 | | ``` Faker::firstname() ``` | Return random firstname |
32 | | ``` Faker::lastname() ``` | Return random lastname |
33 | | ``` Faker::fullname() ``` | Return random fullname |
34 | | ``` Faker::company() ``` | Return random company name |
35 | | ``` Faker::mobile() ``` | Return random mobile number |
36 | | ``` Faker::telephone() ``` | Return random telephone number |
37 | | ``` Faker::email() ``` | Return random email address |
38 | | ``` Faker::domain() ``` | Return random domain |
39 | | ``` Faker::website() ``` | Return random website address |
40 | | ``` Faker::pageUrl() ``` | Return random pageUrl |
41 | | ``` Faker::age($min,$max) ``` | Return random age arguments*("Min" , "Max") |
42 | | ``` Faker::address() ``` | Return random postal address |
43 | | ``` Faker::city() ``` | Return random city name |
44 | | ``` Faker::meliCode() ``` | Return random meli code |
45 |
46 | ## License
47 | The MIT License (MIT). Please see [License File](LICENSE) for more information.
48 |
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "josh/faker",
3 | "description": "A library for generate fake items",
4 | "type": "library",
5 | "license": "MIT",
6 | "authors": [
7 | {
8 | "name": "Alireza Josheghani",
9 | "email": "josheghani.dev@gmail.com"
10 | }
11 | ],
12 | "autoload": {
13 | "psr-4": {
14 | "Josh\\Faker\\": "src/"
15 | },
16 | "files": [
17 | "src/helpers.php"
18 | ]
19 | },
20 | "require": {
21 | "php": ">=5.6"
22 | },
23 | "require-dev": {
24 | "phpunit/phpunit": "^5.6"
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/objects.php:
--------------------------------------------------------------------------------
1 | [
6 | 'عباس', 'وحید', 'علی', 'علیرضا', 'شاهرخ', 'سجاد', 'شایان' , 'حسام' , 'مهدی' ,
7 | 'حسن' , 'حمید','شقایق', 'المیرا', 'شیما', 'مرجان', 'پرستو', 'نگار' , 'ترانه' ,
8 | 'لیلا' , 'مریم' , 'سحر' , 'زهرا' , 'ریحانه' , 'منیر' , 'عطیه' , 'پروانه' , 'ترانه'
9 | ],
10 |
11 | 'families' => [
12 | 'الماسی', 'جوشقانی', 'جمالیان', 'جعفری', 'فیض', 'نیاکان', 'بیات',
13 | 'پیرو' , 'حیدری' , 'نجاران' , 'اسد نژاد' , 'صمدی' , 'اسدی' , 'کریمی' ,
14 | 'حسینی' , 'الماسی' , 'صدیقی' , 'مسقطی' , 'علی دوستی' , 'کریمزاده' , 'کوت آبادی'
15 | ],
16 |
17 | 'companies' => [
18 | 'ای نتورک', 'خاورزمین', 'فرانش', 'کاروانرو', 'اسنپ', 'تپ سی', 'آواتک',
19 | 'بیدینگ' , 'سایت چک آپ' , 'شنبه' , 'دیجی کالا' , 'بامیلو' , 'ایرانسل' ,
20 | 'همراه اول' , 'سرآوا پارس' , 'ایران خودرو' , 'سایپا' , 'تاژ' , 'هومکر' , 'کاموا' ,
21 | 'کانگرو'
22 | ],
23 |
24 | 'address' => [
25 | 'میدان ونک، بزرگراه حقانی، نرسیده به جهانکودک، پ. ۶۳، ط. ۴',
26 | 'تهران ، خيابان گاندي ، خيابان پانزدهم ، پلاک 2',
27 | 'تهران ، خيابان انقلاب ، پلاک 832',
28 | 'تهران ، خيابان استاد نجات الهی ، کوچه شهید محمدی ، پلاک 4',
29 | 'اراک خيابان شهيد بهشتي دانشگاه اراک',
30 | 'خراسان رضوى مشهد قاسم آباد بلوار ميثاق ميثاق 20 خسروي يك',
31 | 'بزرگراه شهید بابایی (غرب به شرق)، روبروی دانشگاه امام حسین (ع)، خروجی حکیمیه، خیابان شهید صدوقی، روبروی ضلع جنوبی شهرک شهید بهشتی خیابان چمن آرا، پردیس واحد دانشگاهی واحد تهران شمال',
32 | 'خیابان آزادی ،نبش خیابان رودکی',
33 | 'بزرگراه همت ،شرق به غرب ،ابتدای جنت آبادشمالی ،کوچه دانش',
34 | 'میدان بسیج ،ابتدای خیابان ابوذر ،جنب شهرداری منطقه 15',
35 | 'شهرکرد ،میدان دفاع مقدس ،جاده رحمتیه ،روبروی ساختمانهای مسکن مهر',
36 | 'تهران خیابان آفریقا،بالاتر از چهار راه جهان کودک ، کوچه شهید صانعی پلاک 15',
37 | 'اردبیل ـ خیابان دانشگاه ـ خیابان 13 آبان ـ پلاک 48',
38 | 'كرج ـ جهانشهر ـ بلوار مولانا ـ بين خيابان كسري شمالي و فرمانداري شمالي ـ قطعه 1397ـ ساختمان نيلوفر',
39 | 'قزوین ـ خيابان فلسطين شرقي ـ نبش خيابان توحيد',
40 | 'تهران سعادت اباد میدان کاج خیابان سرو شرقی نبش خیابان علامه طباطبایی شمالی پلاک ۵'
41 | ],
42 |
43 | 'mailServices' => [
44 | 'gmail.com' , 'mail.com' , 'yahoo.com' , 'outlook.com'
45 | ],
46 |
47 | 'prefixTelePhones' => [
48 | 912 , 931 , 932 , 933 , 901 , 921 , 919 , 912 , 913 , 917 ,
49 | 915 , 916 , 910 , 939 , 938 , 937 , 918 , 914 , 911 , 934
50 | ],
51 |
52 | 'prefixPhones' => [
53 | 21 , 25 , 253 , 32 , 45 , 67 , 11 , 12 , 93 , 65 , 34 , 67
54 | ],
55 |
56 | 'protocols' => [ 'http' , 'https' ],
57 |
58 |
59 | 'domains' => [
60 | '.com' , '.org' , '.ir' , '.net' , '.me' , '.info' , '.co'
61 | ],
62 |
63 | 'city' => [
64 | 'آذربایجان غربی',
65 | 'چهارمحال و بختیاری',
66 | 'سیستان و بلوچستان',
67 | 'کهکیلویه و بویراحمد',
68 | 'فارس',
69 | 'گیلان',
70 | 'همدان',
71 | 'ایلام',
72 | 'هرمزگان',
73 | 'کرمانشاه',
74 | 'خوزستان',
75 | 'کردستان',
76 | 'بوشهر',
77 | 'لرستان',
78 | 'سمنان',
79 | 'تهران',
80 | 'اصفهان',
81 | 'کرمان',
82 | 'اردبیل',
83 | 'آذربایجان شرقی',
84 | 'مرکزی',
85 | 'مازندران',
86 | 'زنجان',
87 | 'گلستان',
88 | 'قزوین',
89 | 'قم',
90 | 'یزد',
91 | 'خراسان جنوبی',
92 | 'خراسان رضوی',
93 | 'خراسان شمالی',
94 | 'البرز'
95 | ]
96 |
97 | ];
--------------------------------------------------------------------------------
/phpunit.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | tests
6 |
7 |
8 |
--------------------------------------------------------------------------------
/src/Faker.php:
--------------------------------------------------------------------------------
1 |
9 | * @since 12 Dec 2016
10 | * @method static fullname()
11 | * @method static firstname()
12 | * @method static lastname()
13 | * @method static telephone()
14 | * @method static age($min = 16,$max = 70)
15 | * @method static email()
16 | * @method static domain()
17 | * @method static website()
18 | * @method static pageUrl()
19 | * @method static company()
20 | * @method static mobile()
21 | * @method static address()
22 | * @method static city()
23 | * @method static meliCode()
24 | */
25 | class Faker
26 | {
27 | /**
28 | * Call method from magic method
29 | *
30 | * @author Alireza Josheghani
31 | * @since 12 Dec 2016
32 | * @param $method
33 | * @return mixed
34 | */
35 | public function __get($method)
36 | {
37 | return faker()->$method();
38 | }
39 |
40 | /**
41 | * @author Alireza Josheghani
42 | * @since 3 Feb 2017
43 | * @param $method
44 | * @param $args
45 | * @return mixed
46 | */
47 | public static function __callStatic($method, $args)
48 | {
49 | return faker()->$method(...$args);
50 | }
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/src/Generator.php:
--------------------------------------------------------------------------------
1 |
19 | * @since 3 Feb 2017
20 | */
21 | public function __construct()
22 | {
23 | $this->objects = require __DIR__ . '/../objects.php';
24 | }
25 |
26 | /**
27 | * Get firtname
28 | *
29 | * @author Alireza Josheghani
30 | * @since 13 Dec 2016
31 | * @return mixed
32 | */
33 | public function firstname()
34 | {
35 | return $this->getRandomKey('names');
36 | }
37 |
38 | /**
39 | * Get last name
40 | *
41 | * @author Alireza Josheghani
42 | * @since 13 Dec 2016
43 | * @return mixed
44 | */
45 | public function lastname()
46 | {
47 | return $this->getRandomKey('families');
48 | }
49 |
50 |
51 | /**
52 | * Get company name
53 | *
54 | * @author Vahid Almasi
55 | * @since 29 Jan 2017
56 | * @return mixed
57 | */
58 | public function company()
59 | {
60 | return $this->getRandomKey('companies');
61 | }
62 |
63 | /**
64 | * Get random firstname and lastname
65 | *
66 | * @author Alireza Josheghani
67 | * @since 13 Dec 2016
68 | * @return string
69 | */
70 | public function fullname()
71 | {
72 | return $this->firstname() . ' ' . $this->lastname();
73 | }
74 |
75 | /**
76 | * Get telephone
77 | *
78 | * @author Alireza Josheghani
79 | * @since 13 Dec 2016
80 | * @return string
81 | */
82 | public function mobile()
83 | {
84 | $prefix = $this->getRandomKey('prefixTelePhones');
85 |
86 | $phone = string('0' . $prefix . randomNumber(7));
87 |
88 | return ( strlen($phone) !== 11 ? $phone . rand(1,10) : $phone );
89 | }
90 |
91 | /**
92 | * Get random phone
93 | *
94 | * @author Alireza Josheghani
95 | * @since 13 Dec 2016
96 | * @return string
97 | */
98 | public function telephone()
99 | {
100 | $prefix = $this->getRandomKey('prefixPhones');
101 |
102 | return string('0' . $prefix . randomNumber(7));
103 | }
104 |
105 | /**
106 | * Get random email
107 | *
108 | * @author Alireza Josheghani
109 | * @since 13 Dec 2016
110 | * @return string
111 | */
112 | public function email()
113 | {
114 | $service = $this->getRandomKey('mailServices');
115 |
116 | return string(randomString(30,'lowercase') . '@' . $service);
117 | }
118 |
119 | /**
120 | * Get random domain
121 | *
122 | * @author Alireza Josheghani
123 | * @since 13 Dec 2016
124 | * @return string
125 | */
126 | public function domain()
127 | {
128 | $domain = $this->getRandomKey('domains');
129 |
130 | return string(randomString(20,'lowercase') . $domain);
131 | }
132 |
133 | /**
134 | * Get random website
135 | *
136 | * @author Alireza Josheghani
137 | * @since 13 Dec 2016
138 | * @return string
139 | */
140 | public function website()
141 | {
142 | $protocol = $this->getRandomKey('domains');
143 |
144 | return string($protocol . '://www' . $this->domain());
145 | }
146 |
147 | /**
148 | * Get random page url
149 | *
150 | * @author Alireza Josheghani
151 | * @since 13 Dec 2016
152 | * @return string
153 | */
154 | public function pageUrl()
155 | {
156 | $rand = rand(3,7);
157 |
158 | $string = '';
159 |
160 | $count = rand(2,8);
161 |
162 | for($i=0;$i < $rand;$i++){
163 | $string .= randomString($count,'lowercase') . '/';
164 | }
165 |
166 | return rtrim($string,'/');
167 | }
168 |
169 | /**
170 | * Get random age
171 | *
172 | * @author Alireza Josheghani
173 | * @since 13 Dec 2016
174 | * @param int $min
175 | * @param int $max
176 | * @return int
177 | */
178 | public function age($min = 16, $max = 70)
179 | {
180 | return rand($min,$max);
181 | }
182 |
183 | /**
184 | * Get random address
185 | *
186 | * @author Vahid Almasi
187 | * @since 3 Feb 2017
188 | * @return mixed
189 | */
190 | public function address()
191 | {
192 | return $this->getRandomKey('address');
193 | }
194 |
195 | /**
196 | * Get random city
197 | *
198 | * @author Vahid Almasi
199 | * @since 4 Feb 2017
200 | * @return mixed
201 | */
202 | public function city()
203 | {
204 | return $this->getRandomKey('city');
205 | }
206 |
207 | /**
208 | * Generate random melicode number
209 | *
210 | * @author Alireza Josheghani
211 | * @since 4 Feb 2017
212 | * @return int|null|string
213 | */
214 | public function meliCode()
215 | {
216 | $code = $this->generateMeliCode();
217 |
218 | if(is_null($code)){
219 | $code = $this->generateMeliCode();
220 | }
221 |
222 | return $code;
223 | }
224 |
225 | /**
226 | * Generate meli code
227 | *
228 | * @author Alireza Josheghani
229 | * @since 5 Feb 2017
230 | * @return int|null|string
231 | */
232 | private function generateMeliCode()
233 | {
234 | $code = null;
235 |
236 | for($i = 1;$i < 100;$i++){
237 |
238 | $meli = randomNumber(10,true);
239 |
240 | if(strlen($meli) != 10){
241 | continue;
242 | }
243 |
244 | $c = substr($meli,9,1);
245 |
246 | $n = substr($meli,0,1) * 10 +
247 | substr($meli,1,1) * 9 +
248 | substr($meli,2,1) * 8 +
249 | substr($meli,3,1) * 7 +
250 | substr($meli,4,1) * 6 +
251 | substr($meli,5,1) * 5 +
252 | substr($meli,6,1) * 4 +
253 | substr($meli,7,1) * 3 +
254 | substr($meli,8,1) * 2;
255 |
256 | $r = $n - (int)($n / 11) * 11;
257 |
258 | if (($r == 0 && $r == $c) || ($r == 1 && $c == 1) || ($r > 1 && $c == 11 - $r)) {
259 |
260 | if(! isMeliCode($meli)){
261 | continue;
262 | }
263 |
264 | $code = $meli;
265 |
266 | } else {
267 | continue;
268 | }
269 |
270 | $i++;
271 | }
272 |
273 | return $code;
274 | }
275 |
276 | /**
277 | * Get random key from array
278 | *
279 | * @author Alireza Josheghani
280 | * @since 4 Feb 2017
281 | * @param $object
282 | * @return string
283 | */
284 | private function getRandomKey($object = null)
285 | {
286 | $name = 0;
287 | $array = [];
288 |
289 | if(is_array($object)){
290 | $array = $object;
291 | $name = array_rand($object);
292 | } elseif(is_string($object)) {
293 | $array = $this->objects[$object];
294 | $name = array_rand($array);
295 | }
296 |
297 | return string($array[$name]);
298 | }
299 |
300 | }
301 |
--------------------------------------------------------------------------------
/src/helpers.php:
--------------------------------------------------------------------------------
1 |
10 | * @since 3 Feb 2016
11 | * @param $value
12 | * @return string
13 | */
14 | function string($value)
15 | {
16 | return (string)$value;
17 | }
18 | }
19 |
20 | if(! function_exists('faker')){
21 | /**
22 | * Return the faker instance
23 | *
24 | * @author Alireza Josheghani
25 | * @since 3 Feb 2016
26 | * @return Generator
27 | */
28 | function faker()
29 | {
30 | return new Generator();
31 | }
32 | }
33 |
34 | if(! function_exists('randomNumber')){
35 | /**
36 | * Return random number
37 | *
38 | * @author Alireza Josheghani
39 | * @since 3 Feb 2016
40 | * @param int $length
41 | * @param bool $int
42 | * @return int|string
43 | */
44 | function randomNumber($length = 20, $int = false)
45 | {
46 | $numbers = "0123456789";
47 |
48 | $number = '';
49 |
50 | for($i = 1;$i <= $length;$i++){
51 | $num = $numbers[rand(0,strlen($numbers) - 1)];
52 |
53 | if($num == 0 && $i == 1){
54 | $i = 1;
55 | continue;
56 | }
57 |
58 | $number .= $num ;
59 | }
60 |
61 | if($int){
62 | return (integer)$number;
63 | }
64 |
65 | return string($number);
66 | }
67 | }
68 |
69 | if(! function_exists('randomString')){
70 |
71 | /**
72 | * Get random string
73 | *
74 | * @author Alireza Josheghani
75 | * @since 13 Dec 2016
76 | * @param int $length
77 | * @param null $type
78 | * @return string
79 | * @throws \Exception
80 | */
81 | function randomString($length = 20, $type = null){
82 |
83 | $characters = [
84 | 'uppercase' => 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
85 | 'lowercase' => 'abcdefghijklmnopqrstuvwxyz'
86 | ];
87 |
88 | if(($type !== 'uppercase' && $type !== 'lowercase') && ! is_null($type)){
89 | throw new \Exception("The type of $type does not exists!");
90 | }
91 |
92 | if(! is_null($type)){
93 | $characters = $characters[$type];
94 | } else {
95 | $characters = $characters['lowercase'] . $characters['uppercase'];
96 | }
97 |
98 | $string = '';
99 |
100 | for($i = 1;$i <= $length;$i++){
101 | $string .= $characters[rand(0,strlen($characters) - 1)];
102 | }
103 |
104 | return $string;
105 | }
106 |
107 | }
108 |
109 | if(! function_exists('isMeliCode')){
110 | /**
111 | * Check is meli code function
112 | *
113 | * @param $value
114 | * @return bool
115 | */
116 | function isMeliCode($value)
117 | {
118 | $sub = 0;
119 | if (!preg_match('/^\d{8,10}$/', $value)) {
120 | return false;
121 | }
122 | if (strlen($value) == 8) {
123 | $value = '00' . $value;
124 | } elseif (strlen($value) == 9) {
125 | $value = '0' . $value;
126 | }
127 | for ($i = 0; $i <= 8; $i++) {
128 | $sub = $sub + ( $value[$i] * ( 10 - $i ) );
129 | }
130 | if (( $sub % 11 ) < 2) {
131 | $control = ( $sub % 11 );
132 | } else {
133 | $control = 11 - ( $sub % 11 );
134 | }
135 | if ($value[9] == $control) {
136 | return true;
137 | } else {
138 | return false;
139 | }
140 | }
141 | }
142 |
--------------------------------------------------------------------------------
/tests/FakerTest.php:
--------------------------------------------------------------------------------
1 | objects = require __DIR__ . '/../objects.php';
20 | }
21 |
22 | /**
23 | * Test firstname genrator
24 | *
25 | * @author Alireza Josheghani
26 | * @since 4 Feb 2017
27 | * @return void
28 | */
29 | public function testFirstName()
30 | {
31 | $this->assertTrue(in_array(Faker::firstname(),$this->objects['names']));
32 | }
33 |
34 | /**
35 | * Test lastname genrator
36 | *
37 | * @author Alireza Josheghani
38 | * @since 4 Feb 2017
39 | * @return void
40 | */
41 | public function testLastName()
42 | {
43 | $this->assertTrue(in_array(Faker::lastname(),$this->objects['families']));
44 | }
45 |
46 | /**
47 | * Test company genrator
48 | *
49 | * @author Alireza Josheghani
50 | * @since 4 Feb 2017
51 | * @return void
52 | */
53 | public function testCompany()
54 | {
55 | $this->assertTrue(in_array(Faker::company(),$this->objects['companies']));
56 | }
57 |
58 | /**
59 | * Test mobile genrator
60 | *
61 | * @author Alireza Josheghani
62 | * @since 4 Feb 2017
63 | * @return void
64 | */
65 | public function testMobile()
66 | {
67 | $phonePrefix = substr(str_replace(0,'',Faker::mobile()), 0, 3);
68 |
69 | $this->assertTrue(in_array($phonePrefix,$this->objects['prefixTelePhones']));
70 | }
71 |
72 | /**
73 | * Test phone genrator
74 | *
75 | * @author Alireza Josheghani
76 | * @since 4 Feb 2017
77 | * @return void
78 | */
79 | public function testPhone()
80 | {
81 | $all = $this->objects['prefixPhones'];
82 |
83 | $test = false;
84 |
85 | for ($i=1;$i < 4;$i++){
86 | $test = in_array(
87 |
88 | substr(str_replace(0,'',Faker::telephone()), 0, $i)
89 |
90 | , $all
91 | );
92 |
93 | if($test){
94 | break;
95 | } else {
96 | continue;
97 | }
98 | }
99 |
100 | $this->assertTrue($test);
101 |
102 | $this->assertNotFalse($test);
103 | }
104 |
105 | /**
106 | * Test age genrator
107 | *
108 | * @author Alireza Josheghani
109 | * @since 4 Feb 2017
110 | * @return void
111 | */
112 | public function testAge()
113 | {
114 | $age = Faker::age();
115 |
116 | $assert = false;
117 |
118 | if($age <= 70 && $age >= 17){
119 | $assert = true;
120 | }
121 |
122 | $this->assertTrue($assert);
123 |
124 | $this->assertNotFalse($assert);
125 | }
126 |
127 | /**
128 | * Test email genrator
129 | *
130 | * @author Alireza Josheghani
131 | * @since 4 Feb 2017
132 | * @return void
133 | */
134 | public function testEmail()
135 | {
136 | $email = Faker::email();
137 |
138 | $this->assertNotFalse(filter_var($email, FILTER_VALIDATE_EMAIL));
139 | }
140 |
141 | /**
142 | * Test domain genrator
143 | *
144 | * @author Alireza Josheghani
145 | * @since 4 Feb 2017
146 | * @return void
147 | */
148 | public function testDomain()
149 | {
150 | $this->assertRegExp('/^(?:[-A-Za-z0-9]+\.)+[A-Za-z]{2,6}$/',Faker::domain());
151 | }
152 |
153 | /**
154 | * Test city genrator
155 | *
156 | * @author Vahid Almasi
157 | * @since 4 Feb 2017
158 | * @return void
159 | */
160 | public function testCity()
161 | {
162 | $this->assertTrue(in_array(Faker::city(),$this->objects['city']));
163 | }
164 |
165 | /**
166 | * Test melicode genrator
167 | *
168 | * @author Alireza Josheghani
169 | * @since 4 Feb 2017
170 | * @return void
171 | */
172 | public function testMeliCode()
173 | {
174 | $this->assertTrue(isMeliCode(Faker::meliCode()));
175 | }
176 |
177 | }
--------------------------------------------------------------------------------