Browse Source

Updated schema to 8.0 in phpunit.xml
Fixed security test by randomizing token names

Tobias Oitzinger 6 years ago
parent
commit
f5535b5fc5
2 changed files with 6 additions and 6 deletions
  1. 1 1
      phpunit.xml
  2. 5 5
      system/tests/ko7/SecurityTest.php

+ 1 - 1
phpunit.xml

@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <phpunit
 		xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-		xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/6.5/phpunit.xsd"
+		xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/8.0/phpunit.xsd"
 		bootstrap="modules/unittest/bootstrap.php"
 		cacheTokens="true"
 		beStrictAboutOutputDuringTests="true"

+ 5 - 5
system/tests/ko7/SecurityTest.php

@@ -70,8 +70,9 @@ class KO7_SecurityTest extends Unittest_TestCase
 		$array = [];
 		for ($i = 0; $i <= 4; $i++)
 		{
-			Security::$token_name = 'token_'.$i;
-			$array[] = [Security::token(TRUE), Security::check(Security::token(FALSE)), $i];
+			$id = uniqid('', FALSE);
+			Security::$token_name = 'token_'.$id;
+			$array[] = [Security::token(TRUE), Security::check(Security::token()), $id];
 		}
 		return $array;
 	}
@@ -79,7 +80,6 @@ class KO7_SecurityTest extends Unittest_TestCase
 	/**
 	 * Tests Security::token()
 	 *
-	 * @test
 	 * @dataProvider provider_csrf_token
 	 * @covers Security::token
 	 */
@@ -87,8 +87,8 @@ class KO7_SecurityTest extends Unittest_TestCase
 	{
 		//@todo: the Security::token tests need to be reviewed to check how much of the logic they're actually covering
 		Security::$token_name = 'token_'.$iteration;
-		$this->assertSame(TRUE, $input);
-		$this->assertSame($expected, Security::token(FALSE));
+		self::assertTrue($input);
+		self::assertSame($expected, Security::token());
 		Session::instance()->delete(Security::$token_name);
 	}
 }