Skip to content
This repository was archived by the owner on Jan 30, 2020. It is now read-only.

Commit 816b0fd

Browse files
committed
Update tests to use PHP 7.2-safe validators
The `EmailAddress` validator is using a deprecated constant, which causes errors in this test suite. As such, updated several tests to use a different validator to ensure we can test on 7.2.
1 parent fa97708 commit 816b0fd

File tree

1 file changed

+21
-23
lines changed

1 file changed

+21
-23
lines changed

test/CollectionInputFilterTest.php

+21-23
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
use Zend\InputFilter\Exception\RuntimeException;
2020
use Zend\InputFilter\Input;
2121
use Zend\InputFilter\InputFilter;
22-
use Zend\Validator\EmailAddress;
22+
use Zend\Validator\Digits;
2323
use Zend\Validator\NotEmpty;
2424

2525
/**
@@ -512,10 +512,10 @@ public function testCollectionValidationDoesNotReuseMessagesBetweenInputs()
512512
{
513513
$inputFilter = new InputFilter();
514514
$inputFilter->add([
515-
'name' => 'email',
515+
'name' => 'phone',
516516
'required' => true,
517517
'validators' => [
518-
['name' => EmailAddress::class],
518+
['name' => Digits::class],
519519
['name' => NotEmpty::class],
520520
],
521521
]);
@@ -535,7 +535,7 @@ public function testCollectionValidationDoesNotReuseMessagesBetweenInputs()
535535
'name' => 'Tom',
536536
],
537537
[
538-
'email' => 'tom@tom',
538+
'phone' => 'tom@tom',
539539
'name' => 'Tom',
540540
],
541541
]);
@@ -547,27 +547,25 @@ public function testCollectionValidationDoesNotReuseMessagesBetweenInputs()
547547
$this->assertFalse($isValid);
548548
$this->assertCount(2, $messages);
549549

550-
$this->assertArrayHasKey('email', $messages[0]);
551-
$this->assertCount(1, $messages[0]['email']);
552-
$this->assertContains('Value is required and can\'t be empty', $messages[0]['email']);
550+
$this->assertArrayHasKey('phone', $messages[0]);
551+
$this->assertCount(1, $messages[0]['phone']);
552+
$this->assertContains('Value is required and can\'t be empty', $messages[0]['phone']);
553553

554-
$this->assertArrayHasKey('email', $messages[1]);
555-
$this->assertCount(3, $messages[1]['email']);
556-
$this->assertNotContains('Value is required and can\'t be empty', $messages[1]['email']);
557-
$this->assertContains('\'tom\' is not a valid hostname for the email address', $messages[1]['email']);
558-
$this->assertContains('The input does not match the expected structure for a DNS hostname', $messages[1]['email']);
559-
$this->assertContains('The input appears to be a local network name but local network names are not allowed', $messages[1]['email']);
554+
$this->assertArrayHasKey('phone', $messages[1]);
555+
$this->assertCount(1, $messages[1]['phone']);
556+
$this->assertNotContains('Value is required and can\'t be empty', $messages[1]['phone']);
557+
$this->assertContains('The input must contain only digits', $messages[1]['phone']);
560558
// @codingStandardsIgnoreEnd
561559
}
562560

563561
public function testCollectionValidationUsesCustomInputErrorMessages()
564562
{
565563
$inputFilter = new InputFilter();
566564
$inputFilter->add([
567-
'name' => 'email',
565+
'name' => 'phone',
568566
'required' => true,
569567
'validators' => [
570-
['name' => EmailAddress::class],
568+
['name' => Digits::class],
571569
['name' => NotEmpty::class],
572570
],
573571
'error_message' => 'CUSTOM ERROR MESSAGE',
@@ -588,7 +586,7 @@ public function testCollectionValidationUsesCustomInputErrorMessages()
588586
'name' => 'Tom',
589587
],
590588
[
591-
'email' => 'tom@tom',
589+
'phone' => 'tom@tom',
592590
'name' => 'Tom',
593591
],
594592
]);
@@ -600,14 +598,14 @@ public function testCollectionValidationUsesCustomInputErrorMessages()
600598
$this->assertFalse($isValid);
601599
$this->assertCount(2, $messages);
602600

603-
$this->assertArrayHasKey('email', $messages[0]);
604-
$this->assertCount(1, $messages[0]['email']);
605-
$this->assertContains('CUSTOM ERROR MESSAGE', $messages[0]['email']);
606-
$this->assertNotContains('Value is required and can\'t be empty', $messages[0]['email']);
601+
$this->assertArrayHasKey('phone', $messages[0]);
602+
$this->assertCount(1, $messages[0]['phone']);
603+
$this->assertContains('CUSTOM ERROR MESSAGE', $messages[0]['phone']);
604+
$this->assertNotContains('Value is required and can\'t be empty', $messages[0]['phone']);
607605

608-
$this->assertArrayHasKey('email', $messages[1]);
609-
$this->assertCount(1, $messages[1]['email']);
610-
$this->assertContains('CUSTOM ERROR MESSAGE', $messages[1]['email']);
606+
$this->assertArrayHasKey('phone', $messages[1]);
607+
$this->assertCount(1, $messages[1]['phone']);
608+
$this->assertContains('CUSTOM ERROR MESSAGE', $messages[1]['phone']);
611609
}
612610

613611
public function testDuplicatedErrorMessages()

0 commit comments

Comments
 (0)