Browse Source

Updated to PHPUnit8, removed some incomplete tests.

Tobias Oitzinger 6 years ago
parent
commit
21789a600f

+ 4 - 5
composer.json

@@ -26,13 +26,12 @@
     "issues": "https://github.com/koseven/koseven/issues"
   },
   "require": {
-    "php": ">=7.0"
+    "php": ">=7.2"
   },
   "require-dev": {
-    "phpunit/phpunit": "^6.0|^7.0",
-    "phpunit/dbunit":"^3.0",
-    "phpunit/phpcov": "^4.0",
-    "php-coveralls/php-coveralls": "^2.0"
+    "phpunit/phpunit": "^8",
+    "php-coveralls/php-coveralls": "^2.0",
+    "ext-curl": "*"
   },
   "conflict": {
     "kohana/core": "3.3.*"

+ 4 - 4
modules/cache/classes/KO7/Cache/Apcu.php

@@ -145,11 +145,11 @@ class KO7_Cache_Apcu extends Cache implements Cache_Arithmetic {
 	 */
 	public function increment($id, $step = 1)
 	{
+		$id = $this->_sanitize_id($id);
 		if (apcu_exists($id)) {
 			return apcu_inc($id, $step);
-		} else {
-			return FALSE;
 		}
+		return FALSE;
 	}
 
 	/**
@@ -164,11 +164,11 @@ class KO7_Cache_Apcu extends Cache implements Cache_Arithmetic {
 	 */
 	public function decrement($id, $step = 1)
 	{
+		$id = $this->_sanitize_id($id);
 		if (apcu_exists($id)) {
 			return apcu_dec($id, $step);
-		} else {
-			return FALSE;
 		}
+		return FALSE;
 	}
 
 } // End KO7_Cache_Apcu

+ 7 - 4
modules/cache/tests/cache/CacheBasicMethodsTest.php

@@ -27,7 +27,7 @@ abstract class KO7_CacheBasicMethodsTest extends Unittest_TestCase {
 	 *
 	 * @return  void
 	 */
-	public function setUp()
+	public function setUp(): void
 	{
 		parent::setUp();
 	}
@@ -87,7 +87,7 @@ TESTTEXT;
 					'value'   => 101010,
 					'ttl'     => 0,
 					'wait'    => FALSE,
-					'type'    => 'integer',
+					'type'    => 'int',
                     'tags'    => ['tag_int'],
 					'default' => NULL
 				],
@@ -129,7 +129,7 @@ TESTTEXT;
 					'value'   => TRUE,
 					'ttl'     => 0,
 					'wait'    => FALSE,
-					'type'    => 'boolean',
+					'type'    => 'bool',
                     'tags'    => ['tag_bool'],
 					'default' => NULL
 				],
@@ -275,7 +275,10 @@ TESTTEXT;
 
 		$result = $cache->get($id, $default);
 		$this->assertEquals($expected, $result);
-		$this->assertInternalType($type, $result);
+
+		$assertIsType = 'assertIs'.ucfirst($type);
+		$assertIsType = $assertIsType === 'assertIsNull' ? 'assertNull' : $assertIsType;
+		$this->$assertIsType($result);
 
 		unset($id, $value, $ttl, $wait, $type, $default);
 	}

+ 1 - 3
modules/cache/tests/cache/CacheTest.php

@@ -70,12 +70,10 @@ class KO7_CacheTest extends Unittest_TestCase {
 
 	/**
 	 * Tests that `clone($cache)` will be prevented to maintain singleton
-	 *
-	 * @return  void
-	 * @expectedException Cache_Exception
 	 */
 	public function test_cloning_fails()
 	{
+		$this->expectException(Cache_Exception::class);
 		$cache = $this->getMockBuilder('Cache')
 			->disableOriginalConstructor()
 			->getMockForAbstractClass();

+ 1 - 1
modules/cache/tests/cache/FileTest.php

@@ -24,7 +24,7 @@ class KO7_Cache_FileTest extends KO7_CacheBasicMethodsTest {
 	 *
 	 * @return  void
 	 */
-	public function setUp()
+	public function setUp(): void
 	{
 		parent::setUp();
 

+ 1 - 1
modules/cache/tests/cache/RedisTest.php

@@ -21,7 +21,7 @@ class KO7_RedisTest extends KO7_CacheBasicMethodsTest {
      * @throws Cache_Exception
      * @throws KO7_Exception
      */
-    public function setUp()
+    public function setUp(): void
     {
         // Check if Redis extension is loaded
         if ( ! extension_loaded('redis'))

+ 1 - 1
modules/cache/tests/cache/SqliteTest.php

@@ -24,7 +24,7 @@ class KO7_SqliteTest extends KO7_CacheBasicMethodsTest {
 	 *
 	 * @return  void
 	 */
-	public function setUp()
+	public function setUp(): void
 	{
 		parent::setUp();
 

+ 1 - 1
modules/cache/tests/cache/WincacheTest.php

@@ -33,7 +33,7 @@ else
 		 *
 		 * @return  void
 		 */
-		public function setUp()
+		public function setUp(): void
 		{
 			parent::setUp();
 

+ 1 - 1
modules/cache/tests/cache/arithmetic/ApcuTest.php

@@ -24,7 +24,7 @@ class KO7_ApcuTest extends KO7_CacheArithmeticMethodsTest {
      *
      * @return  void
      */
-    public function setUp()
+    public function setUp(): void
     {
         parent::setUp();
 

+ 2 - 2
modules/cache/tests/cache/arithmetic/CacheArithmeticMethods.php

@@ -12,7 +12,7 @@ include_once(KO7::find_file('tests/cache', 'CacheBasicMethodsTest'));
  */
 abstract class KO7_CacheArithmeticMethodsTest extends KO7_CacheBasicMethodsTest {
 
-	public function tearDown()
+	public function tearDown(): void
 	{
 		parent::tearDown();
 
@@ -86,7 +86,7 @@ abstract class KO7_CacheArithmeticMethodsTest extends KO7_CacheBasicMethodsTest
 
 		if ($start_state !== NULL)
 		{
-			$cache->set($inc_args['id'], $start_state, 0);
+			$cache->set($inc_args['id'], (int)$start_state, 0);
 		}
 
 		$this->assertSame(

Some files were not shown because too many files changed in this diff