24 lines
703 B
PHP
24 lines
703 B
PHP
|
<?php
|
||
|
/**
|
||
|
* @author Daniel J. Summers <daniel@bitbadger.solutions>
|
||
|
* @license MIT
|
||
|
*/
|
||
|
|
||
|
declare(strict_types=1);
|
||
|
|
||
|
use BitBadger\PDODocument\Mapper\StringMapper;
|
||
|
|
||
|
pest()->group('unit');
|
||
|
|
||
|
describe('->map()', function () {
|
||
|
test('returns existing string column value', function () {
|
||
|
expect(new StringMapper('test_field'))->map(['test_field' => 'test_value'])->toBe('test_value');
|
||
|
});
|
||
|
test('returns string value of non-string column', function () {
|
||
|
expect(new StringMapper('a_number'))->map(['a_number' => 6.7])->toBe('6.7');
|
||
|
});
|
||
|
test('returns null for a missing column', function () {
|
||
|
expect(new StringMapper('something_else'))->map([])->toBeNull();
|
||
|
});
|
||
|
});
|