]> BookStack Code Mirror - bookstack/blobdiff - tests/TestResponse.php
Added testing coverage for tag index
[bookstack] / tests / TestResponse.php
index 5e2be3ac35c103caa3b897dc4fec0fc5d7322984..4e53aa020ba3ca5054e8d75e14a2ed57dc277276 100644 (file)
@@ -53,6 +53,26 @@ class TestResponse extends BaseTestResponse
         return $this;
     }
 
+    /**
+     * Assert the response contains the given count of elements
+     * that match the given css selector.
+     *
+     * @return $this
+     */
+    public function assertElementCount(string $selector, int $count)
+    {
+        $elements = $this->crawler()->filter($selector);
+        PHPUnit::assertTrue(
+            $elements->count() === $count,
+            'Unable to ' . $count . ' element(s) matching the selector: ' . PHP_EOL . PHP_EOL .
+            "[{$selector}]" . PHP_EOL . PHP_EOL .
+            'found ' . $elements->count() . ' within' . PHP_EOL . PHP_EOL .
+            "[{$this->getContent()}]."
+        );
+
+        return $this;
+    }
+
     /**
      * Assert the response does not contain the specified element.
      *