Skip to content

Instantly share code, notes, and snippets.

@jiromm
Created January 20, 2020 05:16
Show Gist options
  • Save jiromm/76faf32123661f169a11af27e9113dbb to your computer and use it in GitHub Desktop.
Save jiromm/76faf32123661f169a11af27e9113dbb to your computer and use it in GitHub Desktop.
<?php
use PHPUnit\Framework\TestCase;
include 'hayk.php';
final class UnitNumberTest extends TestCase
{
/**
* @dataProvider invalidDataProvider
*/
public function testEmptyValues($alpha, $num = 0, $eAlpha = [], $eNum = [], $unit = null)
{
$this->expectException(\Throwable::class);
getNext($alpha, $num, $eAlpha, $eNum, $unit);
}
public function invalidDataProvider()
{
return [
[0],
[-1],
[-5021625],
[1, -1],
[1, 2, [1]],
[1, 2, ['AA']],
[1, 2, ['Ա']],
[1, 2, ['A', 2]],
[1, 2, ['A', 'B', 'C', 'D', '$', 'E']],
[1, 2, range('A', 'Z')],
[1, 2, [], ['A']],
[1, 2, [], [-1]],
[1, 2, [], [11]],
[1, 2, [], ['A', 1]],
[1, 2, [], [1, 2, 'a', 3]],
[1, 2, [], [1, 2, '%', 3]],
[1, 2, [], [-1]],
[1, 2, [], [1, -1, 3]],
[1, 2, [], range(0, 9)],
[1, 2, [], [], '$'],
[1, 2, [], [], 'A$'],
[1, 2, [], [], 'A1$'],
[1, 2, [], [], 'A1$1'],
[1, 2, [], [], '1'],
[1, 2, [], [], '1A'],
[2, 2, [], [], 'XYZ00'],
[1, 2, [], [], ''],
];
}
/**
* @dataProvider validDataProvider
*/
public function testValidValues($alpha, $num, $eAlpha, $eNum, $unit, $returnedResult)
{
$result = getNext($alpha, $num, $eAlpha, $eNum, $unit);
$this->assertEquals($result, $returnedResult);
}
public function validDataProvider()
{
return [
[1, 0, [], [], null, 'A0'],
[1, 5, [], [], null, 'A00000'],
[2, 30, [], [], null, 'AA' . str_repeat('0', 30)],
[2, 2, [], [], 'AB233', 'AB234'],
[2, 2, [], [], 'AZ500', 'AZ501'],
[2, 2, [], [], 'AZ999', 'BA000'],
[2, 2, [], [], 'A456', 'AA00'],
[2, 2, ['A'], [], 'AC123', 'BB000'],
[2, 2, ['A', 'B'], [], 'AC123', 'CC000'],
[1, 0, [], [0], null, 'A1'],
[1, 0, [], [0, 1], null, 'A2'],
[1, 0, [], [0], 'Z9', 'A11'],
[2, 2, ['A', 'B'], [0, 1], 'AC123', 'CC222'],
[3, 2, ['A', 'B', 'C', 'D', 'E', 'F'], [0, 1, 2, 3, 4, 5], 'A1', 'GGG6'],
[2, 2, ['Z'], [0, 9], 'YY889', 'AA1111'],
];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment