mirror of
https://github.com/nothingworksinc/ticketbeast.git
synced 2026-01-26 03:04:05 +00:00
80 - Testing the Confirmation Number Format
This commit is contained in:
11
app/RandomOrderConfirmationNumberGenerator.php
Normal file
11
app/RandomOrderConfirmationNumberGenerator.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
class RandomOrderConfirmationNumberGenerator implements OrderConfirmationNumberGenerator
|
||||
{
|
||||
public function generate()
|
||||
{
|
||||
return str_repeat('A', 24);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
use App\RandomOrderConfirmationNumberGenerator;
|
||||
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
||||
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
@@ -13,4 +14,37 @@ class RandomOrderConfirmationNumberGeneratorTest extends TestCase
|
||||
//
|
||||
// ABCDEFGHJKLMNPQRSTUVWXYZ
|
||||
// 23456789
|
||||
|
||||
/** @test */
|
||||
function must_be_24_characters_long()
|
||||
{
|
||||
$generator = new RandomOrderConfirmationNumberGenerator;
|
||||
|
||||
$confirmationNumber = $generator->generate();
|
||||
|
||||
$this->assertEquals(24, strlen($confirmationNumber));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
function can_only_contain_uppercase_letters_and_numbers()
|
||||
{
|
||||
$generator = new RandomOrderConfirmationNumberGenerator;
|
||||
|
||||
$confirmationNumber = $generator->generate();
|
||||
|
||||
$this->assertRegExp('/^[A-Z0-9]+$/', $confirmationNumber);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
function cannot_contain_ambiguous_characters()
|
||||
{
|
||||
$generator = new RandomOrderConfirmationNumberGenerator;
|
||||
|
||||
$confirmationNumber = $generator->generate();
|
||||
|
||||
$this->assertFalse(strpos($confirmationNumber, '1'));
|
||||
$this->assertFalse(strpos($confirmationNumber, 'I'));
|
||||
$this->assertFalse(strpos($confirmationNumber, '0'));
|
||||
$this->assertFalse(strpos($confirmationNumber, 'O'));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user