|
2 | 2 |
|
3 | 3 | namespace Stevebauman\Location\Tests;
|
4 | 4 |
|
| 5 | +use Illuminate\Support\Arr; |
5 | 6 | use Stevebauman\Location\Position;
|
6 | 7 |
|
| 8 | +it('can be created with attributes array', function (array $attributes, array $expected) { |
| 9 | + $position = Position::make($attributes); |
| 10 | + |
| 11 | + expect(Arr::only($position->toArray(), array_keys($expected)))->toBe($expected); |
| 12 | +})->with([ |
| 13 | + // Camel casing attributes: |
| 14 | + [ |
| 15 | + [ |
| 16 | + 'ip' => '127.0.0.1', |
| 17 | + 'driver' => 'local', |
| 18 | + 'countryName' => 'foo', |
| 19 | + 'countryCode' => 'bar', |
| 20 | + ], |
| 21 | + [ |
| 22 | + 'ip' => '127.0.0.1', |
| 23 | + 'driver' => 'local', |
| 24 | + 'countryName' => 'foo', |
| 25 | + 'countryCode' => 'bar', |
| 26 | + ] |
| 27 | + ], |
| 28 | + // Snake casing attributes: |
| 29 | + [ |
| 30 | + [ |
| 31 | + 'ip' => '127.0.0.1', |
| 32 | + 'driver' => 'local', |
| 33 | + 'country_name' => 'foo', |
| 34 | + 'country_code' => 'bar', |
| 35 | + ], |
| 36 | + [ |
| 37 | + 'ip' => '127.0.0.1', |
| 38 | + 'driver' => 'local', |
| 39 | + 'countryName' => 'foo', |
| 40 | + 'countryCode' => 'bar', |
| 41 | + ] |
| 42 | + ] |
| 43 | +]); |
| 44 | + |
7 | 45 | it('returns empty', function () {
|
8 | 46 | $position = new Position();
|
9 | 47 |
|
10 |
| - $position->ip = '192.168.1.1'; |
| 48 | + $position->ip = '127.0.0.1'; |
11 | 49 | $position->driver = 'foo';
|
12 | 50 |
|
13 | 51 | expect($position->isEmpty())->toBeTrue();
|
|
0 commit comments