mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-04 08:47:23 +08:00
Validate birth date
This commit is contained in:
parent
5911e09310
commit
c77cab9cbe
5 changed files with 81 additions and 35 deletions
32
tests/PHPUnit/WcGateway/Helper/PayUponInvoiceHelperTest.php
Normal file
32
tests/PHPUnit/WcGateway/Helper/PayUponInvoiceHelperTest.php
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace WooCommerce\PayPalCommerce\WcGateway\Helper;
|
||||
|
||||
use DateTime;
|
||||
use WooCommerce\PayPalCommerce\TestCase;
|
||||
|
||||
class PayUponInvoiceHelperTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider datesProvider
|
||||
*/
|
||||
public function testValidateBirthDate($input, $output)
|
||||
{
|
||||
$this->assertSame((new PayUponInvoiceHelper())->validate_birth_date($input), $output);
|
||||
}
|
||||
|
||||
public function datesProvider(): array{
|
||||
$format = 'Y-m-d';
|
||||
|
||||
return [
|
||||
['', false],
|
||||
[(new DateTime())->format($format), false],
|
||||
[(new DateTime('-17 years'))->format($format), false],
|
||||
['31-02-1942', false],
|
||||
['01-01-1942', false],
|
||||
['1942-01-01', true],
|
||||
];
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue