aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMario Vavti <mario@mariovavti.com>2022-03-29 11:42:53 +0200
committerMario Vavti <mario@mariovavti.com>2022-03-29 11:42:53 +0200
commit0784cd593a39a4fc297e8a82f7e79bc8019a0868 (patch)
tree22182afb37cf460f8208fff9d276a0672add3185 /tests
parent0e2e9321025f87fe9587f3d183adaea6185e4e20 (diff)
parent9c5d2ee5630dd7033904039dcd1e92db8821b644 (diff)
downloadvolse-hubzilla-7.2.tar.gz
volse-hubzilla-7.2.tar.bz2
volse-hubzilla-7.2.zip
Merge branch '7.2RC'7.2
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/AntiXSSTest.php20
-rw-r--r--tests/unit/Photo/PhotoGdTest.php5
-rw-r--r--tests/unit/includes/LanguageTest.php5
-rw-r--r--tests/unit/includes/NetworkTest.php33
4 files changed, 58 insertions, 5 deletions
diff --git a/tests/unit/AntiXSSTest.php b/tests/unit/AntiXSSTest.php
index b45042a1e..09642726f 100644
--- a/tests/unit/AntiXSSTest.php
+++ b/tests/unit/AntiXSSTest.php
@@ -24,6 +24,26 @@ class AntiXSSTest extends TestCase {
$this->assertEquals("&lt;submit type=&quot;button&quot; onclick=&quot;alert('failed!');&quot; /&gt;", $escapedString);
}
+ /**
+ * @dataProvider urlTestProvider
+ */
+ public function testEscapeURL($url, $expected) : void {
+ $this->assertEquals($expected, escape_url($url));
+ }
+
+ public function urlTestProvider() : array {
+ return [
+ [
+ "https://example.com/settings/calendar/?f=&rpath=https://example.com/cdav/calendar'><script>alert('boom')</script>",
+ "https://example.com/settings/calendar/?f=&amp;rpath=https://example.com/cdav/calendar&apos;&gt;&lt;script&gt;alert(&apos;boom&apos;)&lt;/script&gt;"
+ ],
+ [
+ "settings/calendar/?f=&rpath=https://example.com'+accesskey=x+onclick=alert(/boom/);a='",
+ "settings/calendar/?f=&amp;rpath=https://example.com&apos;+accesskey=x+onclick=alert(/boom/);a=&apos;"
+ ],
+ ];
+ }
+
/**
*xmlify and unxmlify
*/
diff --git a/tests/unit/Photo/PhotoGdTest.php b/tests/unit/Photo/PhotoGdTest.php
index ae7382c43..1324043c4 100644
--- a/tests/unit/Photo/PhotoGdTest.php
+++ b/tests/unit/Photo/PhotoGdTest.php
@@ -71,11 +71,14 @@ class PhotoGdTest extends UnitTestCase {
/**
* Tests PhotoGd->getImage()
*/
+ /* TODO: fix for PHP8
public function testGetimageReturnsAResource() {
$res = $this->photoGd->getImage();
$this->assertIsResource($res);
$this->assertEquals('gd', get_resource_type($res));
}
+ */
+
public function testGetimageReturnsFalseOnFailure() {
$this->photoGd = new PhotoGd('');
$this->assertFalse($this->photoGd->getImage());
@@ -94,11 +97,13 @@ class PhotoGdTest extends UnitTestCase {
/**
* Tests PhotoGd->rotate()
*/
+ /* TODO: fix for PHP8
public function testRotate360DegreesCreatesANewImage() {
$data = $this->photoGd->getImage();
$this->photoGd->rotate(360);
$this->assertNotEquals($data, $this->photoGd->getImage());
}
+ */
/**
* Tests PhotoGd->flip()
diff --git a/tests/unit/includes/LanguageTest.php b/tests/unit/includes/LanguageTest.php
index 9f1af2b50..9525c783d 100644
--- a/tests/unit/includes/LanguageTest.php
+++ b/tests/unit/includes/LanguageTest.php
@@ -63,11 +63,6 @@ class LanguageTest extends UnitTestCase {
public function languageExamplesProvider() {
return [
- 'empty text' => [
- '',
- '',
- null
- ],
'English' => [
'English is a West Germanic language that was first spoken in early medieval England and is now a global lingua franca.[4][5] Named after the Angles, one of the Germanic tribes that migrated to England, it ultimately derives its name from the Anglia (Angeln) peninsula in the Baltic Sea. It is closely related to the Frisian languages, but its vocabulary has been significantly influenced by other Germanic languages, particularly Norse (a North Germanic language), as well as by Latin and Romance languages, especially French.',
'en',
diff --git a/tests/unit/includes/NetworkTest.php b/tests/unit/includes/NetworkTest.php
new file mode 100644
index 000000000..0b9b42e00
--- /dev/null
+++ b/tests/unit/includes/NetworkTest.php
@@ -0,0 +1,33 @@
+<?php
+/**
+ * tests function from include/network.php
+ *
+ * @package test.util
+ */
+
+use PHPUnit\Framework\TestCase;
+
+require_once('include/network.php');
+
+class NetworkTest extends TestCase {
+
+ public function setup() : void {
+ \App::set_baseurl("https://mytest.org");
+ }
+
+ /**
+ * @dataProvider localUrlTestProvider
+ */
+ public function testIsLocalURL($url, $expected) {
+ $this->assertEquals($expected, is_local_url($url));
+ }
+
+ public function localUrlTestProvider() : array {
+ return [
+ [ '/some/path', true ],
+ [ 'https://mytest.org/some/path', true ],
+ [ 'https://other.site/some/path', false ],
+ ];
+ }
+}
+