object = new Migration(new Uri('mysql://localhost'), __DIR__ . '/dirstructure'); } public function tearDown(): void { $this->object = null; } public function testGetBaseSql() { $base = $this->object->getBaseSql(); $this->assertEquals(__DIR__ . '/dirstructure/base.sql', $base); } public function testGetBaseSqlNotFound() { $this->expectException(InvalidMigrationFile::class); $this->object = new Migration(new Uri('mysql://localhost'), __DIR__ . '/invalid'); $this->object->getBaseSql(); } public function testGetBaseSqlNotFoundAndNotRequired() { $this->object = new Migration(new Uri('mysql://localhost'), __DIR__ . '/invalid', false); $this->object->getBaseSql(); $this->assertTrue(true); } public function testGetMigrationSql1() { $version = $this->object->getMigrationSql(1, 1); $this->assertEquals(__DIR__ . '/dirstructure/migrations/up/00001.sql', $version); } public function testGetMigrationSql2() { $version = $this->object->getMigrationSql(2, 1); $this->assertEquals(__DIR__ . '/dirstructure/migrations/up/00002.sql', $version); } public function testGetMigrationSql3() { $version = $this->object->getMigrationSql(12, 1); $this->assertEquals(__DIR__ . '/dirstructure/migrations/up/00012-dev.sql', $version); } public function testGetMigrationSql4() { $this->expectException(InvalidMigrationFile::class); $this->expectErrorMessage("version number '13'"); $this->object->getMigrationSql(13, 1); } public function testGetMigrationSqlDown1() { $version = $this->object->getMigrationSql(1, -1); $this->assertEquals(__DIR__ . '/dirstructure/migrations/down/00001.sql', $version); } public function testGetMigrationSqlDown2() { $version = $this->object->getMigrationSql(2, -1); $this->assertEquals(__DIR__ . '/dirstructure/migrations/down/00002.sql', $version); } public function testGetMigrationSqlDown3() { $version = $this->object->getMigrationSql(12, -1); $this->assertEquals(__DIR__ . '/dirstructure/migrations/down/00012-dev.sql', $version); } public function testGetMigrationSqlDown4() { $this->expectException(InvalidMigrationFile::class); $this->expectErrorMessage("version number '13'"); $this->object->getMigrationSql(13, -1); } public function testGetFileContent_NonExists() { $this->assertEquals( [ "file" => "non-existent", "description" => "no description provided. Pro tip: use `-- @description:` to define one.", "exists" => false, "checksum" => null, "content" => null, ], $this->object->getFileContent("non-existent") ); } public function testGetFileContent_1() { $this->assertEquals( [ "file" => __DIR__ . '/dirstructure/migrations/up/00001.sql', "description" => "this is a test", "exists" => true, "checksum" => "b937afa57e363c9244fa30844dd11d312694f697", "content" => "-- @description: this is a test\n\nselect * from mysql.users;\n", ], $this->object->getFileContent(__DIR__ . '/dirstructure/migrations/up/00001.sql') ); } public function testGetFileContent_2() { $this->assertEquals( [ "file" => __DIR__ . '/dirstructure/migrations/up/00002.sql', "description" => "another test", "exists" => true, "checksum" => "fd8ab8176291c2dcbf0d91564405e0f98f0cd77e", "content" => "-- @description: another test\n\nselect * from dual;", ], $this->object->getFileContent(__DIR__ . '/dirstructure/migrations/up/00002.sql') ); } public function testGetFileContent_3() { $this->assertEquals( [ "file" => __DIR__ . '/dirstructure/migrations/up/00003.sql', "description" => "no description provided. Pro tip: use `-- @description:` to define one.", "exists" => true, "checksum" => "73faaa68e2f60c11e75a9ccc18528e0ffa15127a", "content" => "select something from sometable;", ], $this->object->getFileContent(__DIR__ . '/dirstructure/migrations/up/00003.sql') ); } } __halt_compiler();----SIGNATURE:----GtUEN3ZwSdzhlpP/EFp8vYr8oCk4LpoQCine68q8HJK5g6w7CB99mTQbqQlei6b78ZBeqpQPgvEfFwk6rq9P9ss/AJtHZ0ILMuybDJJoQ8VQBt/fA8yIsFmJk1U45gxkAqzu8CJFhZz89J4dVZBWl3umYQv//Ugl+5zd0nAD9/CPZo6I9B2tB9XxNZbC3Nu5yAMIddXEXRK0WMX/TpeAEZik53yzlVC0F+mRNzVbczAM3uCRHDejnY9JUZkyLx9fIWrddK8JQIL7B3IpSOO3e6mp2Lvn+ngWMWnWYe3EDzAmTmq+aLfFfuvJhj/rhf0mgpOzX7IZLYfSn/mI7LlgW4fVRSNG/ZNm6BJD5TJdwOjUXhAElI3Grfm2bBusQRZ0XEyghwJBcJcbBWZ04Doa4IGNAKlTkq9Z7pvmKNWj6nf3jwmP82EZBQl/wbm4mUcNbcSzCYAMKYZ+KP2alimhy+A/QQbWs4MItuir+tjW8pk5o7/s55FZdI7a7RaAmxkU7wEebG7dhg8C59KVnxzmfMwzdEaTdzfLETwYG2IA7ykmhHrv7rqSpOMdfJATbjwjK0aiL9aTr1IzQ01UpeqANg8TCK9kfo/iHly9CmGyYhMaQ7w+A+wABVbnyz+z+paZO4RSNKhvSzreiZThmytj30zjDOgbyM4t9PyiwANg3fE=----ATTACHMENT:----MzAzMjE2OTYzMjQxOTY0IDc3NDAwMjc5MjAzMzM0NjcgNzI3NjM4ODk2NjIwNjY5Mg==