-
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from mennodekker/master
Partial fix #15 - labels no longer trimmed for multibyte chars
- Loading branch information
Showing
3 changed files
with
65 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
|
||
namespace SPSS\Tests; | ||
|
||
use SPSS\Sav\Reader; | ||
use SPSS\Sav\Writer; | ||
|
||
class WriteMultibyteTest extends TestCase | ||
{ | ||
|
||
public function testMultiByteLabel() | ||
{ | ||
$data = [ | ||
'header' => [ | ||
'prodName' => '@(#) IBM SPSS STATISTICS', | ||
'layoutCode' => 2, | ||
'creationDate' => date('d M y'), | ||
'creationTime' => date('H:i:s'), | ||
], | ||
'variables' => [ | ||
[ | ||
'name' => 'longname_longerthanexpected', | ||
'label' => 'Data zákończenia', | ||
'width' => 16, | ||
'format' => 1, | ||
], | ||
[ | ||
'name' => 'ccc', | ||
'label' => '12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901233á', | ||
'format' => 5, | ||
'values' => [ | ||
1 => 'Panel', | ||
], | ||
], | ||
], | ||
]; | ||
$writer = new Writer($data); | ||
|
||
$buffer = $writer->getBuffer(); | ||
$buffer->rewind(); | ||
|
||
$reader = Reader::fromString($buffer->getStream())->read(); | ||
|
||
// Sort name | ||
$this->assertEquals($data['variables'][0]['label'], $reader->variables[0]->label); | ||
|
||
// Long name | ||
$this->assertEquals(mb_substr($data['variables'][1]['label'], 0, -1), $reader->variables[1]->label); | ||
} | ||
|
||
} |