Skip to content
This repository has been archived by the owner on Jan 24, 2024. It is now read-only.

Updating deprecated @expectedException annotations #12

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions tests/Migrations/AtomizerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,9 @@ public function testSetPrimaryKeys(): void

public function testChangePrimaryKeys(): void
{
$this->expectException(\Spiral\Migrations\Exception\Operation\TableException::class);
$this->expectExceptionMessageMatches("/Unable to set primary keys for table '.+'\.'.+', table already exists/");

Comment on lines +308 to +310
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$this->expectException(\Spiral\Migrations\Exception\Operation\TableException::class);
$this->expectExceptionMessageMatches("/Unable to set primary keys for table '.+'\.'.+', table already exists/");

//Create thought migration
$this->migrator->configure();

Expand Down
8 changes: 8 additions & 0 deletions tests/Migrations/BlueprintTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ public function testCreateWithForeignAliased(): void
public function testUpdateTableError(): void
{
$this->expectException(\Spiral\Migrations\Exception\Operation\TableException::class);
$this->expectExceptionMessageMatches("/Unable to create table '.+'\.'.+', table already exists/");

$blueprint = new TableBlueprint($capsule = new Capsule($this->db), 'sample');

$blueprint->addColumn('id', 'primary')
Expand Down Expand Up @@ -174,6 +176,8 @@ public function testUpdateTable(): void
public function testUpdateTableError2(): void
{
$this->expectException(\Spiral\Migrations\Exception\Operation\ColumnException::class);
$this->expectExceptionMessageMatches("/Unable to create column '.+'\.'.+', column already exists/");

$blueprint = new TableBlueprint($capsule = new Capsule($this->db), 'sample');

$blueprint->addColumn('id', 'primary')
Expand All @@ -192,6 +196,8 @@ public function testUpdateTableError2(): void
public function testUpdateTableError5(): void
{
$this->expectException(\Spiral\Migrations\Exception\Operation\ColumnException::class);
$this->expectExceptionMessageMatches("/Option '.+' are required to define column with type '.+'/");

$blueprint = new TableBlueprint($capsule = new Capsule($this->db), 'sample');

$blueprint->addColumn('id', 'primary')
Expand All @@ -210,6 +216,8 @@ public function testUpdateTableError5(): void
public function testUpdateTableError3(): void
{
$this->expectException(\Spiral\Migrations\Exception\Operation\IndexException::class);
$this->expectExceptionMessageMatches("/Unable to create index '.+'\.(.+), index already exists/");

$blueprint = new TableBlueprint($capsule = new Capsule($this->db), 'sample');

$blueprint->addColumn('id', 'primary')
Expand Down
60 changes: 60 additions & 0 deletions tests/Migrations/ExceptionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ abstract class ExceptionsTest extends BaseTest

public function testDropNonExisted(): void
{
$this->expectException(\Spiral\Migrations\Exception\Operation\TableException::class);
$this->expectExceptionMessageMatches("/Unable to drop table '.+'\.'.+', table does not exists/");

Comment on lines +35 to +37
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$this->expectException(\Spiral\Migrations\Exception\Operation\TableException::class);
$this->expectExceptionMessageMatches("/Unable to drop table '.+'\.'.+', table does not exists/");

//Create thought migration
$this->migrator->configure();
$this->repository->registerMigration('m', DropNonExistedMigration::class);
Expand All @@ -46,6 +49,9 @@ public function testDropNonExisted(): void

public function testCreateEmpty(): void
{
$this->expectException(\Spiral\Migrations\Exception\Operation\TableException::class);
$this->expectExceptionMessageMatches("/Unable to create table '.+'\.'.+', no columns were added/");

Comment on lines +52 to +54
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$this->expectException(\Spiral\Migrations\Exception\Operation\TableException::class);
$this->expectExceptionMessageMatches("/Unable to create table '.+'\.'.+', no columns were added/");

//Create thought migration
$this->migrator->configure();
$this->repository->registerMigration('m', CreateEmptyMigration::class);
Expand All @@ -60,6 +66,9 @@ public function testCreateEmpty(): void

public function testCreateDuplicate(): void
{
$this->expectException(\Spiral\Migrations\Exception\Operation\TableException::class);
$this->expectExceptionMessageMatches("/Unable to create table '.+'\.'.+', table already exists/");

Comment on lines +69 to +71
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$this->expectException(\Spiral\Migrations\Exception\Operation\TableException::class);
$this->expectExceptionMessageMatches("/Unable to create table '.+'\.'.+', table already exists/");

//Create thought migration
$this->migrator->configure();

Expand All @@ -79,6 +88,9 @@ public function testCreateDuplicate(): void

public function testUpdateNonExisted(): void
{
$this->expectException(\Spiral\Migrations\Exception\Operation\TableException::class);
$this->expectExceptionMessageMatches("/Unable to update table '.+'\.'.+', no table exists/");

Comment on lines +91 to +93
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$this->expectException(\Spiral\Migrations\Exception\Operation\TableException::class);
$this->expectExceptionMessageMatches("/Unable to update table '.+'\.'.+', no table exists/");

//Create thought migration
$this->migrator->configure();

Expand All @@ -94,6 +106,9 @@ public function testUpdateNonExisted(): void

public function testRenameNonExisted(): void
{
$this->expectException(\Spiral\Migrations\Exception\Operation\TableException::class);
$this->expectExceptionMessageMatches("/Unable to rename table '.+'\.'.+', table does not exists/");

Comment on lines +109 to +111
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$this->expectException(\Spiral\Migrations\Exception\Operation\TableException::class);
$this->expectExceptionMessageMatches("/Unable to rename table '.+'\.'.+', table does not exists/");

//Create thought migration
$this->migrator->configure();

Expand All @@ -109,6 +124,9 @@ public function testRenameNonExisted(): void

public function testRenameButBusy(): void
{
$this->expectException(\Spiral\Migrations\Exception\Operation\TableException::class);
$this->expectExceptionMessageMatches("/Unable to rename table '.+'\.'.+', table '.+' already exists/");

Comment on lines +127 to +129
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$this->expectException(\Spiral\Migrations\Exception\Operation\TableException::class);
$this->expectExceptionMessageMatches("/Unable to rename table '.+'\.'.+', table '.+' already exists/");

//Create thought migration
$this->migrator->configure();

Expand All @@ -132,6 +150,9 @@ public function testRenameButBusy(): void

public function testDuplicateColumn(): void
{
$this->expectException(\Spiral\Migrations\Exception\Operation\ColumnException::class);
$this->expectExceptionMessageMatches("/Unable to create column '.+'\.'.+', column already exists/");

Comment on lines +153 to +155
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$this->expectException(\Spiral\Migrations\Exception\Operation\ColumnException::class);
$this->expectExceptionMessageMatches("/Unable to create column '.+'\.'.+', column already exists/");

//Create thought migration
$this->migrator->configure();

Expand All @@ -152,6 +173,9 @@ public function testDuplicateColumn(): void

public function testDropNonExistedIndex(): void
{
$this->expectException(\Spiral\Migrations\Exception\Operation\IndexException::class);
$this->expectExceptionMessageMatches("/Unable to drop index '.+'\.(.+), index does not exists/");

Comment on lines +176 to +178
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$this->expectException(\Spiral\Migrations\Exception\Operation\IndexException::class);
$this->expectExceptionMessageMatches("/Unable to drop index '.+'\.(.+), index does not exists/");

//Create thought migration
$this->migrator->configure();

Expand All @@ -172,6 +196,9 @@ public function testDropNonExistedIndex(): void

public function testAlterNonExistedIndex(): void
{
$this->expectException(\Spiral\Migrations\Exception\Operation\IndexException::class);
$this->expectExceptionMessageMatches("/Unable to alter index '.+'\.(.+), no such index/");

Comment on lines +199 to +201
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$this->expectException(\Spiral\Migrations\Exception\Operation\IndexException::class);
$this->expectExceptionMessageMatches("/Unable to alter index '.+'\.(.+), no such index/");

//Create thought migration
$this->migrator->configure();

Expand All @@ -192,6 +219,9 @@ public function testAlterNonExistedIndex(): void

public function testAlterNonExistedColumn(): void
{
$this->expectException(\Spiral\Migrations\Exception\Operation\ColumnException::class);
$this->expectExceptionMessageMatches("/Unable to alter column '.+'\.'.+', column does not exists/");

Comment on lines +222 to +224
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$this->expectException(\Spiral\Migrations\Exception\Operation\ColumnException::class);
$this->expectExceptionMessageMatches("/Unable to alter column '.+'\.'.+', column does not exists/");

//Create thought migration
$this->migrator->configure();

Expand All @@ -211,6 +241,9 @@ public function testAlterNonExistedColumn(): void

public function testRenameNonExistedColumn(): void
{
$this->expectException(\Spiral\Migrations\Exception\Operation\ColumnException::class);
$this->expectExceptionMessageMatches("/Unable to rename column '.+'\.'.+', column does not exists/");

Comment on lines +244 to +246
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$this->expectException(\Spiral\Migrations\Exception\Operation\ColumnException::class);
$this->expectExceptionMessageMatches("/Unable to rename column '.+'\.'.+', column does not exists/");

//Create thought migration
$this->migrator->configure();

Expand All @@ -230,6 +263,9 @@ public function testRenameNonExistedColumn(): void

public function testRenameDuplicateExistedColumn(): void
{
$this->expectException(\Spiral\Migrations\Exception\Operation\ColumnException::class);
$this->expectExceptionMessageMatches("/Unable to rename column '.+'\.'.+', column '.+' already exists/");

Comment on lines +266 to +268
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$this->expectException(\Spiral\Migrations\Exception\Operation\ColumnException::class);
$this->expectExceptionMessageMatches("/Unable to rename column '.+'\.'.+', column '.+' already exists/");

//Create thought migration
$this->migrator->configure();

Expand All @@ -251,6 +287,9 @@ public function testRenameDuplicateExistedColumn(): void

public function testAddForeignNoTarget(): void
{
$this->expectException(\Spiral\Migrations\Exception\Operation\ForeignKeyException::class);
$this->expectExceptionMessageMatches("/Unable to add foreign key 'tests_sample'.'column', foreign table 'target' does not exists/");

Comment on lines +290 to +292
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$this->expectException(\Spiral\Migrations\Exception\Operation\ForeignKeyException::class);
$this->expectExceptionMessageMatches("/Unable to add foreign key 'tests_sample'.'column', foreign table 'target' does not exists/");

//Create thought migration
$this->migrator->configure();

Expand All @@ -272,6 +311,9 @@ public function testAddForeignNoTarget(): void

public function testAddForeignNoTargetColumn(): void
{
$this->expectException(\Spiral\Migrations\Exception\Operation\ForeignKeyException::class);
$this->expectExceptionMessageMatches("/Unable to add foreign key '.+'\.'.+', foreign column '.+'\.'.+' does not exists/");

Comment on lines +314 to +316
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$this->expectException(\Spiral\Migrations\Exception\Operation\ForeignKeyException::class);
$this->expectExceptionMessageMatches("/Unable to add foreign key '.+'\.'.+', foreign column '.+'\.'.+' does not exists/");

//Create thought migration
$this->migrator->configure();

Expand All @@ -297,6 +339,9 @@ public function testAddForeignNoTargetColumn(): void

public function testAlterForeignNoFK(): void
{
$this->expectException(\Spiral\Migrations\Exception\Operation\ForeignKeyException::class);
$this->expectExceptionMessageMatches("/Unable to alter foreign key '.+'\.(.+), key does not exists/");

Comment on lines +342 to +344
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$this->expectException(\Spiral\Migrations\Exception\Operation\ForeignKeyException::class);
$this->expectExceptionMessageMatches("/Unable to alter foreign key '.+'\.(.+), key does not exists/");

//Create thought migration
$this->migrator->configure();

Expand All @@ -317,6 +362,9 @@ public function testAlterForeignNoFK(): void

public function testAlterForeignNoTable(): void
{
$this->expectException(\Spiral\Migrations\Exception\Operation\ForeignKeyException::class);
$this->expectExceptionMessageMatches("/Unable to alter foreign key '.+'\.'.+', foreign table '.+' does not exists/");

Comment on lines +365 to +367
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$this->expectException(\Spiral\Migrations\Exception\Operation\ForeignKeyException::class);
$this->expectExceptionMessageMatches("/Unable to alter foreign key '.+'\.'.+', foreign table '.+' does not exists/");

//Create thought migration
$this->migrator->configure();

Expand All @@ -343,6 +391,9 @@ public function testAlterForeignNoTable(): void

public function testAlterForeignNoColumn(): void
{
$this->expectException(\Spiral\Migrations\Exception\Operation\ForeignKeyException::class);
$this->expectExceptionMessageMatches("/Unable to alter foreign key '.+'\.'.+', foreign column '.+'\.'.+' does not exists/");

Comment on lines +394 to +396
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$this->expectException(\Spiral\Migrations\Exception\Operation\ForeignKeyException::class);
$this->expectExceptionMessageMatches("/Unable to alter foreign key '.+'\.'.+', foreign column '.+'\.'.+' does not exists/");

//Create thought migration
$this->migrator->configure();

Expand Down Expand Up @@ -373,6 +424,9 @@ public function testAlterForeignNoColumn(): void

public function testDropNonExistedFK(): void
{
$this->expectException(\Spiral\Migrations\Exception\Operation\ForeignKeyException::class);
$this->expectExceptionMessageMatches("/Unable to drop foreign key '.+'\.'.+', foreign key does not exists/");

Comment on lines +427 to +429
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$this->expectException(\Spiral\Migrations\Exception\Operation\ForeignKeyException::class);
$this->expectExceptionMessageMatches("/Unable to drop foreign key '.+'\.'.+', foreign key does not exists/");

//Create thought migration
$this->migrator->configure();

Expand All @@ -394,6 +448,9 @@ public function testDropNonExistedFK(): void

public function testAddExisted(): void
{
$this->expectException(\Spiral\Migrations\Exception\Operation\ForeignKeyException::class);
$this->expectExceptionMessageMatches("/Unable to add foreign key '.+'\.(.+), foreign key already exists/");

Comment on lines +451 to +453
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$this->expectException(\Spiral\Migrations\Exception\Operation\ForeignKeyException::class);
$this->expectExceptionMessageMatches("/Unable to add foreign key '.+'\.(.+), foreign key already exists/");

//Create thought migration
$this->migrator->configure();

Expand Down Expand Up @@ -439,20 +496,23 @@ public function testBadDateFormatMigrationFile(): void
public function testDuplicateClassMigration(): void
{
$this->expectException(\Spiral\Migrations\Exception\RepositoryException::class);
$this->expectExceptionMessageMatches("/Unable to register migration '.+', migration already exists/");
$this->repository->registerMigration('unique_name_1', DuplicateColumnMigration::class);
$this->repository->registerMigration('unique_name_2', DuplicateColumnMigration::class);
}

public function testDuplicateFileNameMigration(): void
{
$this->expectException(\Spiral\Migrations\Exception\RepositoryException::class);
$this->expectExceptionMessageMatches("/Unable to register migration 'camel_case_duplicate', migration under the same name already exists/");
$this->repository->registerMigration('camel_case_duplicate', DuplicateColumnMigration::class);
$this->repository->registerMigration('camelCaseDuplicate', CreateEmptyMigration::class);
}

public function testInvalidMigration(): void
{
$this->expectException(\Spiral\Migrations\Exception\RepositoryException::class);
$this->expectExceptionMessageMatches("/Unable to register migration '.+', representing class does not exists/");
$this->repository->registerMigration('m', 'invalid');
}
}
1 change: 1 addition & 0 deletions tests/Migrations/MigratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ public function testCapsule(): void
public function testCapsuleException(): void
{
$this->expectException(\Spiral\Migrations\Exception\CapsuleException::class);
$this->expectExceptionMessageMatches("/Migration operation expected to be an instance of `.+`, `.+` given/");
$capsule = new Capsule($this->db);

$capsule->execute([
Expand Down