]> git.agnieray.net Git - galette.git/blobdiff - tests/Galette/Core/tests/units/Preferences.php
Check website URL is valid; closes #1789
[galette.git] / tests / Galette / Core / tests / units / Preferences.php
index f5a492cc030b14206529dc7910abaa70beb8d556..5b92752ef4acf36b309c09c12691f50ddb3c773a 100644 (file)
@@ -657,4 +657,30 @@ class Preferences extends TestCase
             $legend['socials']['patterns']['asso_social_mynewtype']
         );
     }
+
+    /**
+     * Test website URL
+     *
+     * @return void
+     */
+    public function testWebsiteURL(): void
+    {
+        $preferences = [];
+        foreach ($this->preferences->getDefaults() as $key => $value) {
+            $preferences[$key] = $value;
+        }
+
+        $post = array_merge($preferences, ['pref_website' => 'https://galette.eu']);
+        $this->assertTrue(
+            $this->preferences->check($post, $this->login),
+            print_r($this->preferences->getErrors(), true)
+        );
+
+        $post = array_merge($preferences, ['pref_website' => 'galette.eu']);
+        $this->assertFalse(
+            $this->preferences->check($post, $this->login),
+            print_r($this->preferences->getErrors(), true)
+        );
+        $this->assertSame(['- Invalid website URL.'], $this->preferences->getErrors());
+    }
 }