Skip to content

Commit c6fa791

Browse files
committed
Add dataProviders to test against string and file resource binary readers
1 parent af8b1d6 commit c6fa791

8 files changed

Lines changed: 527 additions & 448 deletions

File tree

test/AbstractTestCase.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
namespace PhpBinaryReader;
4+
5+
class AbstractTestCase extends \PHPUnit_Framework_TestCase
6+
{
7+
// Data provider for creating both File and String based binary readers.
8+
public function binaryReaders()
9+
{
10+
$fileBig = __DIR__ . '/asset/testfile-big.bin';
11+
$fileLittle = __DIR__ . '/asset/testfile-little.bin';
12+
13+
$dataBig = fopen($fileBig, 'rb');
14+
$dataLittle = fopen($fileLittle, 'rb');
15+
16+
$brBigFile = new BinaryReader(fopen($fileBig, 'rb'), Endian::ENDIAN_BIG);
17+
$brLittleFile = new BinaryReader(fopen($fileLittle, 'rb'), Endian::ENDIAN_LITTLE);
18+
19+
$brBigStr = new BinaryReader(file_get_contents($fileBig), Endian::ENDIAN_BIG);
20+
$brLittleStr = new BinaryReader(file_get_contents($fileLittle), Endian::ENDIAN_LITTLE);
21+
22+
return [
23+
[$brBigFile, $brLittleFile],
24+
[$brBigStr, $brLittleStr],
25+
];
26+
}
27+
}

0 commit comments

Comments
 (0)