From ece99b817455db850fe9c17163f2ef8c5280952e Mon Sep 17 00:00:00 2001 From: peter279k Date: Sat, 29 Feb 2020 00:22:55 +0800 Subject: [PATCH] Test enhancement --- .travis.yml | 3 ++- composer.json | 2 +- tests/AbstractConfigTest.php | 6 +++--- tests/Writer/IniTest.php | 2 +- tests/Writer/JsonTest.php | 2 +- tests/Writer/XmlTest.php | 2 +- tests/Writer/YamlTest.php | 2 +- 7 files changed, 10 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index 14d3d8e..11cb8a4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,13 +8,14 @@ php: - 7.1 - 7.2 - 7.3 + - 7.4 cache: directories: - $HOME/.composer/cache install: - - travis_retry composer update --no-interaction --no-progress --no-suggest --prefer-dist + - travis_retry composer install --no-interaction --no-progress --no-suggest --prefer-dist script: - vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover diff --git a/composer.json b/composer.json index c1e7e45..aa2f31b 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ "php": ">=5.5.9" }, "require-dev": { - "phpunit/phpunit": "~4.8 || ~5.7 || ~6.5 || ~7.5", + "phpunit/phpunit": "~4.8.36 || ~5.7 || ~6.5 || ~7.5", "scrutinizer/ocular": "~1.1", "squizlabs/php_codesniffer": "~2.2", "symfony/yaml": "~3.4" diff --git a/tests/AbstractConfigTest.php b/tests/AbstractConfigTest.php index 2a280de..56ae0ac 100644 --- a/tests/AbstractConfigTest.php +++ b/tests/AbstractConfigTest.php @@ -148,7 +148,7 @@ public function testSetArray() 'host' => 'localhost', 'name' => 'mydatabase' ]); - $this->assertTrue(is_array($this->config->get('database'))); + $this->assertInternalType('array', $this->config->get('database')); $this->assertEquals('localhost', $this->config->get('database.host')); } @@ -161,7 +161,7 @@ public function testCacheWithNestedArray() 'host' => 'localhost', 'name' => 'mydatabase' ]); - $this->assertTrue(is_array($this->config->get('database'))); + $this->assertInternalType('array', $this->config->get('database')); $this->config->set('database.host', '127.0.0.1'); $expected = [ 'host' => '127.0.0.1', @@ -227,7 +227,7 @@ public function testSetAndUnsetArray() 'host' => 'localhost', 'name' => 'mydatabase' ]); - $this->assertTrue(is_array($this->config->get('database'))); + $this->assertInternalType('array', $this->config->get('database')); $this->assertEquals('localhost', $this->config->get('database.host')); $this->config->set('database.host', null); $this->assertNull($this->config->get('database.host')); diff --git a/tests/Writer/IniTest.php b/tests/Writer/IniTest.php index de28a76..8eaef11 100644 --- a/tests/Writer/IniTest.php +++ b/tests/Writer/IniTest.php @@ -90,7 +90,7 @@ public function testWriteIni() $this->writer->toFile($this->data, $this->temp_file); $this->assertFileExists($this->temp_file); - $this->assertEquals(file_get_contents($this->temp_file), file_get_contents(__DIR__.'/../mocks/pass/config4.ini')); + $this->assertFileEquals($this->temp_file, __DIR__.'/../mocks/pass/config4.ini'); } /** diff --git a/tests/Writer/JsonTest.php b/tests/Writer/JsonTest.php index 980607d..4e4cc9f 100644 --- a/tests/Writer/JsonTest.php +++ b/tests/Writer/JsonTest.php @@ -84,7 +84,7 @@ public function testWriteJson() $this->writer->toFile($this->data, $this->temp_file); $this->assertFileExists($this->temp_file); - $this->assertEquals(file_get_contents($this->temp_file), file_get_contents(__DIR__.'/../mocks/pass/config4.json')); + $this->assertFileEquals($this->temp_file, __DIR__.'/../mocks/pass/config4.json'); } /** diff --git a/tests/Writer/XmlTest.php b/tests/Writer/XmlTest.php index 3dc5b79..a7407b8 100644 --- a/tests/Writer/XmlTest.php +++ b/tests/Writer/XmlTest.php @@ -89,7 +89,7 @@ public function testWriteXml() $this->writer->toFile($this->data, $this->temp_file); $this->assertFileExists($this->temp_file); - $this->assertEquals(file_get_contents($this->temp_file), file_get_contents(__DIR__.'/../mocks/pass/config4.xml')); + $this->assertFileEquals($this->temp_file, __DIR__.'/../mocks/pass/config4.xml'); } /** diff --git a/tests/Writer/YamlTest.php b/tests/Writer/YamlTest.php index 2c69640..0788a97 100644 --- a/tests/Writer/YamlTest.php +++ b/tests/Writer/YamlTest.php @@ -93,7 +93,7 @@ public function testWriteYaml() { $this->writer->toFile($this->data, $this->temp_file); $this->assertFileExists($this->temp_file); - $this->assertEquals(file_get_contents($this->temp_file), file_get_contents(__DIR__.'/../mocks/pass/config4.yaml')); + $this->assertFileEquals($this->temp_file, __DIR__.'/../mocks/pass/config4.yaml'); } /**