Skip to content

Commit f546a48

Browse files
committed
Merge 4.x into 5.x
Resolve conflicts: - EntryCommandTest: Use minimal assertions without backend-specific text - PostgresAdapterTest: Use flexible assertions for identity column syntax - PendingMigrationsMiddlewareTest: Use assertInstanceOf for proper type checking
2 parents 620d8a1 + 7dbc620 commit f546a48

4 files changed

Lines changed: 20 additions & 31 deletions

File tree

composer.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,10 @@
4646
},
4747
"autoload-dev": {
4848
"psr-4": {
49+
"Blog\\": "tests/test_app/Plugin/Blog/src/",
4950
"Cake\\Test\\": "./vendor/cakephp/cakephp/tests/",
5051
"Migrations\\Test\\": "tests/",
52+
"Migrator\\": "tests/test_app/Plugin/Migrator/src/",
5153
"SimpleSnapshot\\": "tests/test_app/Plugin/SimpleSnapshot/src/",
5254
"TestApp\\": "tests/test_app/App/",
5355
"TestBlog\\": "tests/test_app/Plugin/TestBlog/src/",

tests/TestCase/Command/EntryCommandTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ public function testExecuteHelp()
4141
$this->exec('migrations --help');
4242

4343
$this->assertExitSuccess();
44-
$this->assertOutputContains('migrations:');
4544
$this->assertOutputContains('migrations migrate');
4645
$this->assertOutputContains('migrations status');
4746
$this->assertOutputContains('migrations rollback');

tests/TestCase/Db/Adapter/PostgresAdapterTest.php

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2454,24 +2454,18 @@ public function testDumpCreateTable()
24542454
->addColumn('column3', 'string', ['default' => 'test', 'null' => false])
24552455
->save();
24562456

2457-
if ($this->usingPostgres10()) {
2458-
$expectedOutput = 'CREATE TABLE "public"."table1" ("id" INT NOT NULL GENERATED BY DEFAULT AS IDENTITY, ' .
2459-
'"column1" VARCHAR DEFAULT NULL, ' .
2460-
'"column2" INT DEFAULT NULL, ' .
2461-
'"column3" VARCHAR NOT NULL DEFAULT \'test\', ' .
2462-
'CONSTRAINT "table1_pkey" PRIMARY KEY ("id"));';
2463-
} else {
2464-
$expectedOutput = 'CREATE TABLE "public"."table1" ("id" SERIAL NOT NULL, ' .
2465-
'"column1" VARCHAR DEFAULT NULL, ' .
2466-
'"column2" INT DEFAULT NULL, "column3" VARCHAR NOT NULL DEFAULT \'test\', ' .
2467-
'CONSTRAINT "table1_pkey" PRIMARY KEY ("id"));';
2468-
}
24692457
$actualOutput = join("\n", $this->out->messages());
2458+
// Check for key parts of the CREATE TABLE statement
2459+
// The identity column syntax varies between CakePHP/database versions
24702460
$this->assertStringContainsString(
2471-
$expectedOutput,
2461+
'CREATE TABLE "public"."table1"',
24722462
$actualOutput,
24732463
'Passing the --dry-run option does not dump create table query',
24742464
);
2465+
$this->assertStringContainsString('"column1" VARCHAR DEFAULT NULL', $actualOutput);
2466+
$this->assertStringContainsString('"column2" INT DEFAULT NULL', $actualOutput);
2467+
$this->assertStringContainsString('"column3" VARCHAR NOT NULL DEFAULT \'test\'', $actualOutput);
2468+
$this->assertStringContainsString('CONSTRAINT "table1_pkey" PRIMARY KEY ("id")', $actualOutput);
24752469
}
24762470

24772471
public function testDumpCreateTableWithSchema()
@@ -2487,22 +2481,18 @@ public function testDumpCreateTableWithSchema()
24872481
->addColumn('column3', 'string', ['default' => 'test', 'null' => false])
24882482
->save();
24892483

2490-
if ($this->usingPostgres10()) {
2491-
$expectedOutput = 'CREATE TABLE "schema1"."table1" ("id" INT NOT NULL GENERATED BY DEFAULT AS IDENTITY, ' .
2492-
'"column1" VARCHAR DEFAULT NULL, ' .
2493-
'"column2" INT DEFAULT NULL, "column3" VARCHAR NOT NULL DEFAULT \'test\', CONSTRAINT ' .
2494-
'"table1_pkey" PRIMARY KEY ("id"));';
2495-
} else {
2496-
$expectedOutput = 'CREATE TABLE "schema1"."table1" ("id" SERIAL NOT NULL, "column1" VARCHAR DEFAULT NULL, ' .
2497-
'"column2" INT DEFAULT NULL, "column3" VARCHAR NOT NULL DEFAULT \'test\', CONSTRAINT ' .
2498-
'"table1_pkey" PRIMARY KEY ("id"));';
2499-
}
25002484
$actualOutput = join("\n", $this->out->messages());
2485+
// Check for key parts of the CREATE TABLE statement
2486+
// The identity column syntax varies between CakePHP/database versions
25012487
$this->assertStringContainsString(
2502-
$expectedOutput,
2488+
'CREATE TABLE "schema1"."table1"',
25032489
$actualOutput,
25042490
'Passing the --dry-run option does not dump create table query',
25052491
);
2492+
$this->assertStringContainsString('"column1" VARCHAR DEFAULT NULL', $actualOutput);
2493+
$this->assertStringContainsString('"column2" INT DEFAULT NULL', $actualOutput);
2494+
$this->assertStringContainsString('"column3" VARCHAR NOT NULL DEFAULT \'test\'', $actualOutput);
2495+
$this->assertStringContainsString('CONSTRAINT "table1_pkey" PRIMARY KEY ("id")', $actualOutput);
25062496
}
25072497

25082498
/**

tests/TestCase/Middleware/PendingMigrationsMiddlewareTest.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ public function testAppMigrationsFail(): void
7878
}
7979

8080
/**
81-
* @doesNotPerformAssertions
8281
* @return void
8382
*/
8483
public function testAppMigrationsSuccess(): void
@@ -103,8 +102,8 @@ public function testAppMigrationsSuccess(): void
103102
$handler = new TestRequestHandler(function ($req) {
104103
return new Response();
105104
});
106-
$response = $middleware->process($request, $handler);
107-
$this->assertNotEmpty($response);
105+
$result = $middleware->process($request, $handler);
106+
$this->assertInstanceOf(Response::class, $result);
108107
}
109108

110109
/**
@@ -131,7 +130,6 @@ public function testAppAndPluginsMigrationsFail(): void
131130
}
132131

133132
/**
134-
* @doesNotPerformAssertions
135133
* @return void
136134
*/
137135
public function testAppAndPluginsMigrationsSuccess(): void
@@ -161,7 +159,7 @@ public function testAppAndPluginsMigrationsSuccess(): void
161159
return new Response();
162160
});
163161

164-
$response = $middleware->process($request, $handler);
165-
$this->assertNotEmpty($response);
162+
$result = $middleware->process($request, $handler);
163+
$this->assertInstanceOf(Response::class, $result);
166164
}
167165
}

0 commit comments

Comments
 (0)