Skip to content

Commit

Permalink
Restrict the first name to 20 characters
Browse files Browse the repository at this point in the history
  • Loading branch information
chinleung committed Mar 8, 2021
1 parent a2f1fab commit 6c58000
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function setEmail(string $email): self
*/
public function setFirstName(string $firstName): self
{
$this->firstName = $firstName;
$this->firstName = substr($firstName, 0, 20);

return $this;
}
Expand Down
28 changes: 28 additions & 0 deletions tests/CustomerTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace ChinLeung\Converge\Tests;

use ChinLeung\Converge\Customer;
use Illuminate\Support\Arr;
use Orchestra\Testbench\TestCase;

class CustomerTest extends TestCase
{
/**
* The first name of the customer will be truncated to 20 characters.
*
* @test
* @return void
*/
public function the_first_name_will_be_truncated_to_20_characters(): void
{
$customer = Customer::make()->setFirstName(
'Uvuvwevwevwe Onyetenyevwe Ugwemuhwem Osas'
);

$this->assertEquals(
'Uvuvwevwevwe Onyeten',
Arr::get($customer->toPayload(), 'ssl_first_name')
);
}
}

0 comments on commit 6c58000

Please sign in to comment.