Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,10 @@
},
"autoload-dev": {
"psr-4": {
"Blog\\": "tests/test_app/Plugin/Blog/src/",
"Cake\\Test\\": "./vendor/cakephp/cakephp/tests/",
"Migrations\\Test\\": "tests/",
"Migrator\\": "tests/test_app/Plugin/Migrator/src/",
"SimpleSnapshot\\": "tests/test_app/Plugin/SimpleSnapshot/src/",
"TestApp\\": "tests/test_app/App/",
"TestBlog\\": "tests/test_app/Plugin/TestBlog/src/"
Expand Down
1 change: 0 additions & 1 deletion tests/TestCase/Command/EntryCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ public function testExecuteHelp()

$this->assertExitSuccess();
$this->assertOutputContains('Using <info>builtin</info> backend');
$this->assertOutputContains('Available Commands');
$this->assertOutputContains('migrations migrate');
$this->assertOutputContains('migrations status');
$this->assertOutputContains('migrations rollback');
Expand Down
36 changes: 14 additions & 22 deletions tests/TestCase/Db/Adapter/PostgresAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2505,23 +2505,18 @@ public function testDumpCreateTable()
->addColumn('column3', 'string', ['default' => 'test', 'null' => false])
->save();

if ($this->usingPostgres10()) {
$expectedOutput = 'CREATE TABLE "public"."table1" ("id" SERIAL NOT NULL, ' .
'"column1" VARCHAR DEFAULT NULL, ' .
'"column2" INT DEFAULT NULL, "column3" VARCHAR NOT NULL DEFAULT \'test\', ' .
'CONSTRAINT "table1_pkey" PRIMARY KEY ("id"));';
} else {
$expectedOutput = 'CREATE TABLE "public"."table1" ("id" SERIAL NOT NULL, ' .
'"column1" VARCHAR DEFAULT NULL, ' .
'"column2" INT DEFAULT NULL, "column3" VARCHAR NOT NULL DEFAULT \'test\', ' .
'CONSTRAINT "table1_pkey" PRIMARY KEY ("id"));';
}
$actualOutput = join("\n", $this->out->messages());
// Check for key parts of the CREATE TABLE statement
// The identity column syntax varies between CakePHP/database versions
$this->assertStringContainsString(
$expectedOutput,
'CREATE TABLE "public"."table1"',
$actualOutput,
'Passing the --dry-run option does not dump create table query',
);
$this->assertStringContainsString('"column1" VARCHAR DEFAULT NULL', $actualOutput);
$this->assertStringContainsString('"column2" INT DEFAULT NULL', $actualOutput);
$this->assertStringContainsString('"column3" VARCHAR NOT NULL DEFAULT \'test\'', $actualOutput);
$this->assertStringContainsString('CONSTRAINT "table1_pkey" PRIMARY KEY ("id")', $actualOutput);
}

public function testDumpCreateTableWithSchema()
Expand All @@ -2537,21 +2532,18 @@ public function testDumpCreateTableWithSchema()
->addColumn('column3', 'string', ['default' => 'test', 'null' => false])
->save();

if ($this->usingPostgres10()) {
$expectedOutput = 'CREATE TABLE "schema1"."table1" ("id" SERIAL NOT NULL, "column1" VARCHAR DEFAULT NULL, ' .
'"column2" INT DEFAULT NULL, "column3" VARCHAR NOT NULL DEFAULT \'test\', CONSTRAINT ' .
'"table1_pkey" PRIMARY KEY ("id"));';
} else {
$expectedOutput = 'CREATE TABLE "schema1"."table1" ("id" SERIAL NOT NULL, "column1" VARCHAR DEFAULT NULL, ' .
'"column2" INT DEFAULT NULL, "column3" VARCHAR NOT NULL DEFAULT \'test\', CONSTRAINT ' .
'"table1_pkey" PRIMARY KEY ("id"));';
}
$actualOutput = join("\n", $this->out->messages());
// Check for key parts of the CREATE TABLE statement
// The identity column syntax varies between CakePHP/database versions
$this->assertStringContainsString(
$expectedOutput,
'CREATE TABLE "schema1"."table1"',
$actualOutput,
'Passing the --dry-run option does not dump create table query',
);
$this->assertStringContainsString('"column1" VARCHAR DEFAULT NULL', $actualOutput);
$this->assertStringContainsString('"column2" INT DEFAULT NULL', $actualOutput);
$this->assertStringContainsString('"column3" VARCHAR NOT NULL DEFAULT \'test\'', $actualOutput);
$this->assertStringContainsString('CONSTRAINT "table1_pkey" PRIMARY KEY ("id")', $actualOutput);
}

/**
Expand Down
8 changes: 4 additions & 4 deletions tests/TestCase/Middleware/PendingMigrationsMiddlewareTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ public function testAppMigrationsFail(): void
}

/**
* @doesNotPerformAssertions
* @return void
*/
public function testAppMigrationsSuccess(): void
Expand All @@ -103,7 +102,8 @@ public function testAppMigrationsSuccess(): void
$handler = new TestRequestHandler(function ($req) {
return new Response();
});
$middleware->process($request, $handler);
$result = $middleware->process($request, $handler);
$this->assertInstanceOf(Response::class, $result);
}

/**
Expand All @@ -130,7 +130,6 @@ public function testAppAndPluginsMigrationsFail(): void
}

/**
* @doesNotPerformAssertions
* @return void
*/
public function testAppAndPluginsMigrationsSuccess(): void
Expand Down Expand Up @@ -160,6 +159,7 @@ public function testAppAndPluginsMigrationsSuccess(): void
return new Response();
});

$middleware->process($request, $handler);
$result = $middleware->process($request, $handler);
$this->assertInstanceOf(Response::class, $result);
}
}
16 changes: 8 additions & 8 deletions tests/TestCase/Migration/ManagerFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ class ManagerFactoryTest extends TestCase
{
public function testConnection(): void
{
$this->out = new StubConsoleOutput();
$this->out->setOutputAs(StubConsoleOutput::PLAIN);
$this->in = new StubConsoleInput([]);
$out = new StubConsoleOutput();
$out->setOutputAs(StubConsoleOutput::PLAIN);
$in = new StubConsoleInput([]);

$io = new ConsoleIo($this->out, $this->out, $this->in);
$io = new ConsoleIo($out, $out, $in);

$factory = new ManagerFactory(['connection' => 'test']);
$result = $factory->createManager($io);
Expand All @@ -28,11 +28,11 @@ public function testConnection(): void

public function testDsnConnection(): void
{
$this->out = new StubConsoleOutput();
$this->out->setOutputAs(StubConsoleOutput::PLAIN);
$this->in = new StubConsoleInput([]);
$out = new StubConsoleOutput();
$out->setOutputAs(StubConsoleOutput::PLAIN);
$in = new StubConsoleInput([]);

$io = new ConsoleIo($this->out, $this->out, $this->in);
$io = new ConsoleIo($out, $out, $in);

$factory = new ManagerFactory(['connection' => 'mysql://root@127.0.0.1/db_tmp']);
$result = $factory->createManager($io);
Expand Down
10 changes: 10 additions & 0 deletions tests/test_app/Plugin/Blog/src/BlogPlugin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
declare(strict_types=1);

namespace Blog;

use Cake\Core\BasePlugin;

class BlogPlugin extends BasePlugin
{
}
10 changes: 10 additions & 0 deletions tests/test_app/Plugin/Migrator/src/MigratorPlugin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
declare(strict_types=1);

namespace Migrator;

use Cake\Core\BasePlugin;

class MigratorPlugin extends BasePlugin
{
}