File tree Expand file tree Collapse file tree 2 files changed +36
-1
lines changed
src/DataConverter/Field/DBase
tests/DataConverter/Field/DBase Expand file tree Collapse file tree 2 files changed +36
-1
lines changed Original file line number Diff line number Diff line change @@ -27,6 +27,6 @@ public function toBinaryString($value): string
2727 $ value = $ this ->encoder ->encode ($ value , 'utf-8 ' , $ outCharset );
2828 }
2929
30- return str_pad ($ value ?? '' , $ this ->column ->length );
30+ return str_pad (( string ) $ value , $ this ->column ->length );
3131 }
3232}
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace XBase \Tests \DataConverter \Field \DBase ;
6+
7+ use PHPUnit \Framework \TestCase ;
8+ use XBase \DataConverter \Encoder \EncoderInterface ;
9+ use XBase \DataConverter \Field \DBase \CharConverter ;
10+ use XBase \Header \Column ;
11+ use XBase \Table \Table ;
12+
13+ /**
14+ * @coversDefaultClass \XBase\DataConverter\Field\DBase\CharConverter
15+ */
16+ class CharConverterTest extends TestCase
17+ {
18+ public function testNullValue (): void
19+ {
20+ $ table = $ this ->createMock (Table::class);
21+ $ column = new Column (['length ' => 1 ]);
22+ $ encoder = $ this ->createMock (EncoderInterface::class);
23+ $ c = new CharConverter ($ table , $ column , $ encoder );
24+ self ::assertSame (' ' , $ c ->toBinaryString (null ));
25+ }
26+
27+ public function testIntValue (): void
28+ {
29+ $ table = $ this ->createMock (Table::class);
30+ $ column = new Column (['length ' => 1 ]);
31+ $ encoder = $ this ->createMock (EncoderInterface::class);
32+ $ c = new CharConverter ($ table , $ column , $ encoder );
33+ self ::assertSame ('1 ' , $ c ->toBinaryString (1 ));
34+ }
35+ }
You can’t perform that action at this time.
0 commit comments