From a5f3cb40b1d53245ad915b071900a9f4b4ac61a7 Mon Sep 17 00:00:00 2001 From: Tom Schlick Date: Wed, 15 Apr 2020 23:27:35 -0400 Subject: [PATCH] update to allow laravel 7 (#18) * Update composer.json * Update .gitignore * require laravel 7 for new version * update test to match parent * remove php 7.1 * allow phpunit 8 or 9 * assertRegExp() -> assertMatchesRegularExpression() * more phpunit changes * replace assertNotContains with assertStringNotContainsString * travis config updates * require phpunit ^9.1 * revert assertRegExp change --- .gitignore | 1 + .travis.yml | 5 ++--- composer.json | 8 ++++---- tests/MigrateDumpTest.php | 2 +- tests/MigrateHookTest.php | 8 ++++---- tests/Mysql/MigrateDumpTest.php | 6 +++--- tests/Sqlite/SqliteTestCase.php | 4 ++-- 7 files changed, 17 insertions(+), 17 deletions(-) diff --git a/.gitignore b/.gitignore index a98d436..95ed6b5 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ vendor coverage .idea .vscode +.phpunit.result.cache diff --git a/.travis.yml b/.travis.yml index 2bcc7d9..3aeaa9e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,14 +1,13 @@ language: php php: -- 7.1 - 7.2 - 7.3 - 7.4 env: matrix: - #- COMPOSER_FLAGS="--prefer-lowest" # Disabled until works w/7.4 (2019-12-04) + - COMPOSER_FLAGS="--prefer-lowest" - COMPOSER_FLAGS="" services: @@ -25,7 +24,7 @@ before_script: - psql -c 'CREATE ROLE root SUPERUSER LOGIN;' -U postgres script: -- vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover --configuration phpunit.xml.travis +- vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover --configuration phpunit.xml.travis --testdox after_script: - php vendor/bin/ocular code-coverage:upload --format=php-clover coverage.clover diff --git a/composer.json b/composer.json index 84c7e1e..e48cf79 100644 --- a/composer.json +++ b/composer.json @@ -22,13 +22,13 @@ } ], "require": { - "php": "^7.1", - "laravel/framework": "^5.8 | ^6.0" + "php": "^7.2.5", + "laravel/framework": "^7.0" }, "require-dev": { "mockery/mockery": "~1.0", - "orchestra/testbench": "^3.7", - "phpunit/phpunit": "^7.0" + "orchestra/testbench": "^5.0", + "phpunit/phpunit": "^8.4|^9.0" }, "autoload": { "psr-4": { diff --git a/tests/MigrateDumpTest.php b/tests/MigrateDumpTest.php index 990b9ec..de90a34 100644 --- a/tests/MigrateDumpTest.php +++ b/tests/MigrateDumpTest.php @@ -33,6 +33,6 @@ public function test_dump_callsAfterDumpClosure() $schema_sql = file_get_contents( database_path() . MigrateDumpCommand::SCHEMA_SQL_PATH_SUFFIX ); - $this->assertNotContains('/*', $schema_sql); + $this->assertStringNotContainsString('/*', $schema_sql); } } diff --git a/tests/MigrateHookTest.php b/tests/MigrateHookTest.php index 12b1d6e..cfb7ce2 100644 --- a/tests/MigrateHookTest.php +++ b/tests/MigrateHookTest.php @@ -24,8 +24,8 @@ public function test_handle() $this->assertEquals(0, $result); $output_string = $output->fetch(); - $this->assertContains('Loaded schema', $output_string); - $this->assertContains('Dumped schema', $output_string); + $this->assertStringContainsString('Loaded schema', $output_string); + $this->assertStringContainsString('Dumped schema', $output_string); } public function test_handle_dumpsOnRollback() @@ -44,7 +44,7 @@ public function test_handle_dumpsOnRollback() $this->assertEquals(0, $result); $output_string = $output->fetch(); - $this->assertContains('Dumped schema', $output_string); + $this->assertStringContainsString('Dumped schema', $output_string); } public function test_handle_doesNotLoadWhenDbHasMigrated() @@ -61,7 +61,7 @@ public function test_handle_doesNotLoadWhenDbHasMigrated() $this->assertEquals(0, $result); $output_string = $output->fetch(); - $this->assertNotContains('Loaded schema', $output_string); + $this->assertStringNotContainsString('Loaded schema', $output_string); $this->assertEquals(1, \DB::table('test_ms')->count()); } diff --git a/tests/Mysql/MigrateDumpTest.php b/tests/Mysql/MigrateDumpTest.php index 8c6953f..d9c060c 100644 --- a/tests/Mysql/MigrateDumpTest.php +++ b/tests/Mysql/MigrateDumpTest.php @@ -16,9 +16,9 @@ public function test_handle() $this->assertDirectoryExists($this->schemaSqlDirectory); $this->assertFileExists($this->schemaSqlPath); $result_sql = file_get_contents($this->schemaSqlPath); - $this->assertContains('CREATE TABLE `test_ms`', $result_sql); - $this->assertContains('INSERT INTO `migrations`', $result_sql); - $this->assertNotContains(' AUTO_INCREMENT=', $result_sql); + $this->assertStringContainsString('CREATE TABLE `test_ms`', $result_sql); + $this->assertStringContainsString('INSERT INTO `migrations`', $result_sql); + $this->assertStringNotContainsString(' AUTO_INCREMENT=', $result_sql); $last_character = mb_substr($result_sql, -1); $this->assertRegExp("/[\r\n]\z/mu", $last_character); } diff --git a/tests/Sqlite/SqliteTestCase.php b/tests/Sqlite/SqliteTestCase.php index 3e7445d..f4f35c1 100644 --- a/tests/Sqlite/SqliteTestCase.php +++ b/tests/Sqlite/SqliteTestCase.php @@ -9,9 +9,9 @@ abstract class SqliteTestCase extends TestCase { protected $dbDefault = 'sqlite'; - public static function setUpBeforeClass() + public static function setUpBeforeClass() : void { // File must exist before connection will initialize, even if empty. touch(__DIR__ . '/../../vendor/orchestra/testbench-core/laravel/database/database.sqlite'); } -} \ No newline at end of file +}