Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 10 additions & 14 deletions tests/Code39/CharacterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,12 @@ public function testToString()
$this->assertSame('a', strval($character));
}

public function testTerminatorCharacter()
/**
* @dataProvider terminatorBarLayoutProvider
*/
public function testBarLayouts($character, $expectedBarLayout)
{
$expectedBarLayout = array(
array(1, true),
array(3, false),
array(1, true),
array(1, false),
array(3, true),
array(1, false),
array(3, true),
array(1, false),
array(1, true)
);

$character = new Character( chr(255) );
$character = new Character( $character );
$bars = $character->getBars();
$this->assertCount(count($expectedBarLayout), $bars);

Expand All @@ -45,4 +36,9 @@ public function testInvalidCharacter()
$this->setExpectedException( 'InvalidArgumentException' );
new Character( chr(129) );
}

public function terminatorBarLayoutProvider()
{
return include __DIR__ . '/../fixtures/Character/bar-layouts.php';
}
}
17 changes: 17 additions & 0 deletions tests/fixtures/Character/bar-layouts.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php
return array(
array(
chr(255), /* character */
array( /* expected bar layout */
array(1, true),
array(3, false),
array(1, true),
array(1, false),
array(3, true),
array(1, false),
array(3, true),
array(1, false),
array(1, true)
)
)
);