Version 1
[yaffs-website] / vendor / jcalderonzumba / gastonjs / tests / unit / BrowserAuthenticationTest.php
diff --git a/vendor/jcalderonzumba/gastonjs/tests/unit/BrowserAuthenticationTest.php b/vendor/jcalderonzumba/gastonjs/tests/unit/BrowserAuthenticationTest.php
new file mode 100644 (file)
index 0000000..c962683
--- /dev/null
@@ -0,0 +1,23 @@
+<?php
+
+namespace Zumba\GastonJS\Tests;
+
+/**
+ * Class BrowserAuthenticationTest
+ * @package Zumba\GastonJS\Tests\Server
+ */
+class BrowserAuthenticationTest extends BrowserCommandsTestCase {
+
+  public function testAuthenticationFails() {
+    $this->visitUrl($this->getTestPageBaseUrl() . "/basic-auth-required/");
+    $this->assertEquals(401, $this->browser->getStatusCode());
+    $this->assertContains("NOT_AUTHORIZED", $this->browser->getBody());
+  }
+
+  public function testAuthenticationSuccess() {
+    $this->browser->setHttpAuth("test", "test");
+    $this->visitUrl($this->getTestPageBaseUrl() . "/basic-auth-required/");
+    $this->assertEquals(200, $this->browser->getStatusCode());
+    $this->assertContains("AUTHORIZATION_OK", $this->browser->getBody());
+  }
+}