1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
<?php
namespace Faker\Test\Provider;
use Faker\Calculator\Ean;
use Faker\Calculator\Isbn;
use Faker\Provider\Barcode;
use Faker\Test\TestCase;
/**
* @group legacy
*/
final class BarcodeTest extends TestCase
{
public function testEan8()
{
$code = $this->faker->ean8();
self::assertMatchesRegularExpression('/^\d{8}$/i', $code);
self::assertTrue(Ean::isValid($code));
}
public function testEan13()
{
$code = $this->faker->ean13();
self::assertMatchesRegularExpression('/^\d{13}$/i', $code);
self::assertTrue(Ean::isValid($code));
}
public function testIsbn10(): void
{
$code = $this->faker->isbn10();
self::assertMatchesRegularExpression('/^\d{9}[0-9X]$/i', $code);
self::assertTrue(Isbn::isValid($code));
}
public function testIsbn13(): void
{
$code = $this->faker->isbn13();
self::assertMatchesRegularExpression('/^\d{13}$/i', $code);
self::assertTrue(Ean::isValid($code));
}
protected function getProviders(): iterable
{
yield new Barcode($this->faker);
}
}
|