]> source.dussan.org Git - nextcloud-server.git/commitdiff
Compare arrays not json strings 836/head
authorRoeland Jago Douma <roeland@famdouma.nl>
Wed, 7 Sep 2016 21:06:18 +0000 (23:06 +0200)
committerRoeland Jago Douma <roeland@famdouma.nl>
Wed, 7 Sep 2016 21:06:18 +0000 (23:06 +0200)
In php 7.1 the pretty print json output changed. Thus now we compare
arrays.

tests/lib/IntegrityCheck/CheckerTest.php

index d67f1382dc9fbecc7d3f9e7597546786aa4ef61e..5823ac0f25cb2a0ae6716aa1bbdba9f99c126302 100644 (file)
@@ -102,8 +102,13 @@ class CheckerTest extends TestCase {
                        ->expects($this->once())
                        ->method('file_put_contents')
                        ->with(
-                                       \OC::$SERVERROOT . '/tests/data/integritycheck/app//appinfo/signature.json',
-                                       $expectedSignatureFileData
+                                       $this->equalTo(\OC::$SERVERROOT . '/tests/data/integritycheck/app//appinfo/signature.json'),
+                                       $this->callback(function($signature) use ($expectedSignatureFileData) {
+                                               $expectedArray = json_decode($expectedSignatureFileData, true);
+                                               $actualArray = json_decode($signature, true);
+                                               $this->assertEquals($expectedArray, $actualArray);
+                                               return true;
+                                       })
                        );
 
                $keyBundle = file_get_contents(__DIR__ .'/../../data/integritycheck/SomeApp.crt');
@@ -456,7 +461,12 @@ class CheckerTest extends TestCase {
                                ->method('file_put_contents')
                                ->with(
                                                \OC::$SERVERROOT . '/tests/data/integritycheck/app//core/signature.json',
-                                               $expectedSignatureFileData
+                                               $this->callback(function($signature) use ($expectedSignatureFileData) {
+                                               $expectedArray = json_decode($expectedSignatureFileData, true);
+                                               $actualArray = json_decode($signature, true);
+                                               $this->assertEquals($expectedArray, $actualArray);
+                                               return true;
+                                               })
                                );
 
                $keyBundle = file_get_contents(__DIR__ .'/../../data/integritycheck/core.crt');
@@ -486,7 +496,12 @@ class CheckerTest extends TestCase {
                                ->method('file_put_contents')
                                ->with(
                                                \OC::$SERVERROOT . '/tests/data/integritycheck/htaccessUnmodified//core/signature.json',
-                                               $expectedSignatureFileData
+                                       $this->callback(function($signature) use ($expectedSignatureFileData) {
+                                               $expectedArray = json_decode($expectedSignatureFileData, true);
+                                               $actualArray = json_decode($signature, true);
+                                               $this->assertEquals($expectedArray, $actualArray);
+                                               return true;
+                                       })
                                );
 
                $keyBundle = file_get_contents(__DIR__ .'/../../data/integritycheck/core.crt');
@@ -511,7 +526,12 @@ class CheckerTest extends TestCase {
                                ->method('file_put_contents')
                                ->with(
                                                \OC::$SERVERROOT . '/tests/data/integritycheck/htaccessWithInvalidModifiedContent//core/signature.json',
-                                               $expectedSignatureFileData
+                                       $this->callback(function($signature) use ($expectedSignatureFileData) {
+                                               $expectedArray = json_decode($expectedSignatureFileData, true);
+                                               $actualArray = json_decode($signature, true);
+                                               $this->assertEquals($expectedArray, $actualArray);
+                                               return true;
+                                       })
                                );
 
                $keyBundle = file_get_contents(__DIR__ .'/../../data/integritycheck/core.crt');
@@ -542,7 +562,12 @@ class CheckerTest extends TestCase {
                                ->method('file_put_contents')
                                ->with(
                                                \OC::$SERVERROOT . '/tests/data/integritycheck/htaccessWithValidModifiedContent/core/signature.json',
-                                               $expectedSignatureFileData
+                                       $this->callback(function($signature) use ($expectedSignatureFileData) {
+                                               $expectedArray = json_decode($expectedSignatureFileData, true);
+                                               $actualArray = json_decode($signature, true);
+                                               $this->assertEquals($expectedArray, $actualArray);
+                                               return true;
+                                       })
                                );
 
                $keyBundle = file_get_contents(__DIR__ .'/../../data/integritycheck/core.crt');