Browse Source

Also cover remaining getIterator() method

ravage84 2 years ago
parent
commit
0f2fdcdd3b
1 changed files with 14 additions and 0 deletions
  1. 14 0
      tests/TestCase/Validation/ValidatorTest.php

+ 14 - 0
tests/TestCase/Validation/ValidatorTest.php

@@ -1709,6 +1709,20 @@ class ValidatorTest extends TestCase
     }
 
     /**
+     * Tests the getIterator method
+     */
+    public function testGetIterator(): void
+    {
+        $validator = new Validator();
+        $validator
+            ->add('email', 'alpha', ['rule' => 'alphanumeric'])
+            ->add('title', 'cool', ['rule' => 'isCool', 'provider' => 'thing']);
+        $fieldIterator = $validator->getIterator();
+        $this->assertInstanceOf(\Traversable::class, $fieldIterator);
+        $this->assertCount(2, $validator);
+    }
+
+    /**
      * Tests the countable interface
      */
     public function testCount(): void