-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
Make test data providers static and declare array return types in QueryBuilderTest class.
#20635
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
terabytesoftw
wants to merge
2
commits into
yiisoft:master
Choose a base branch
from
terabytesoftw:fix-test-4
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,7 +11,6 @@ | |
| use yii\db\Expression; | ||
| use yii\db\Query; | ||
| use yiiunit\data\base\TraversableObject; | ||
| use yiiunit\framework\support\DbHelper; | ||
|
|
||
| /** | ||
| * @group db | ||
|
|
@@ -254,7 +253,7 @@ public function columnTypes() | |
| return array_merge(parent::columnTypes(), []); | ||
| } | ||
|
|
||
| public function batchInsertProvider() | ||
| public static function batchInsertProvider(): array | ||
| { | ||
| $data = parent::batchInsertProvider(); | ||
|
|
||
|
|
@@ -265,7 +264,7 @@ public function batchInsertProvider() | |
| return $data; | ||
| } | ||
|
|
||
| public function insertProvider() | ||
| public static function insertProvider(): array | ||
| { | ||
| return [ | ||
| 'regular-values' => [ | ||
|
|
@@ -278,9 +277,9 @@ public function insertProvider() | |
| 'related_id' => null, | ||
| ], | ||
| [], | ||
| $this->replaceQuotes('SET NOCOUNT ON;DECLARE @temporary_inserted TABLE ([id] int , [email] varchar(128) , [name] varchar(128) NULL, [address] text NULL, [status] int NULL, [profile_id] int NULL);' . | ||
| 'SET NOCOUNT ON;DECLARE @temporary_inserted TABLE ([id] int , [email] varchar(128) , [name] varchar(128) NULL, [address] text NULL, [status] int NULL, [profile_id] int NULL);' . | ||
| 'INSERT INTO [customer] ([email], [name], [address], [is_active], [related_id]) OUTPUT INSERTED.[id],INSERTED.[email],INSERTED.[name],INSERTED.[address],INSERTED.[status],INSERTED.[profile_id] INTO @temporary_inserted VALUES (:qp0, :qp1, :qp2, :qp3, :qp4);' . | ||
| 'SELECT * FROM @temporary_inserted'), | ||
| 'SELECT * FROM @temporary_inserted', | ||
| [ | ||
| ':qp0' => '[email protected]', | ||
| ':qp1' => 'silverfire', | ||
|
|
@@ -302,6 +301,7 @@ public function insertProvider() | |
| [ | ||
| ':qp0' => null, | ||
| ], | ||
| false, | ||
| ], | ||
| 'carry passed params' => [ | ||
| 'customer', | ||
|
|
@@ -314,9 +314,9 @@ public function insertProvider() | |
| 'col' => new Expression('CONCAT(:phFoo, :phBar)', [':phFoo' => 'foo']), | ||
| ], | ||
| [':phBar' => 'bar'], | ||
| $this->replaceQuotes('SET NOCOUNT ON;DECLARE @temporary_inserted TABLE ([id] int , [email] varchar(128) , [name] varchar(128) NULL, [address] text NULL, [status] int NULL, [profile_id] int NULL);' . | ||
| 'SET NOCOUNT ON;DECLARE @temporary_inserted TABLE ([id] int , [email] varchar(128) , [name] varchar(128) NULL, [address] text NULL, [status] int NULL, [profile_id] int NULL);' . | ||
| 'INSERT INTO [customer] ([email], [name], [address], [is_active], [related_id], [col]) OUTPUT INSERTED.[id],INSERTED.[email],INSERTED.[name],INSERTED.[address],INSERTED.[status],INSERTED.[profile_id] INTO @temporary_inserted VALUES (:qp1, :qp2, :qp3, :qp4, :qp5, CONCAT(:phFoo, :phBar));' . | ||
| 'SELECT * FROM @temporary_inserted'), | ||
| 'SELECT * FROM @temporary_inserted', | ||
| [ | ||
| ':phBar' => 'bar', | ||
| ':qp1' => '[email protected]', | ||
|
|
@@ -347,9 +347,9 @@ public function insertProvider() | |
| 'col' => new Expression('CONCAT(:phFoo, :phBar)', [':phFoo' => 'foo']), | ||
| ]), | ||
| [':phBar' => 'bar'], | ||
| $this->replaceQuotes('SET NOCOUNT ON;DECLARE @temporary_inserted TABLE ([id] int , [email] varchar(128) , [name] varchar(128) NULL, [address] text NULL, [status] int NULL, [profile_id] int NULL);' . | ||
| 'SET NOCOUNT ON;DECLARE @temporary_inserted TABLE ([id] int , [email] varchar(128) , [name] varchar(128) NULL, [address] text NULL, [status] int NULL, [profile_id] int NULL);' . | ||
| 'INSERT INTO [customer] ([email], [name], [address], [is_active], [related_id]) OUTPUT INSERTED.[id],INSERTED.[email],INSERTED.[name],INSERTED.[address],INSERTED.[status],INSERTED.[profile_id] INTO @temporary_inserted SELECT [email], [name], [address], [is_active], [related_id] FROM [customer] WHERE ([email]=:qp1) AND ([name]=:qp2) AND ([address]=:qp3) AND ([is_active]=:qp4) AND ([related_id] IS NULL) AND ([col]=CONCAT(:phFoo, :phBar));' . | ||
| 'SELECT * FROM @temporary_inserted'), | ||
| 'SELECT * FROM @temporary_inserted', | ||
| [ | ||
| ':phBar' => 'bar', | ||
| ':qp1' => '[email protected]', | ||
|
|
@@ -375,7 +375,7 @@ public function testResetSequence(): void | |
| $this->assertEquals($expected, $sql); | ||
| } | ||
|
|
||
| public function upsertProvider() | ||
| public static function upsertProvider(): array | ||
| { | ||
| $concreteData = [ | ||
| 'regular values' => [ | ||
|
|
@@ -430,7 +430,7 @@ public function upsertProvider() | |
|
|
||
| public static function conditionProvider(): array | ||
| { | ||
| $data = array_merge( | ||
| return array_merge( | ||
| parent::conditionProvider(), | ||
| [ | ||
| [ | ||
|
|
@@ -462,28 +462,26 @@ public static function conditionProvider(): array | |
| ], | ||
| //[ ['in', ['id', 'name'], (new Query())->select(['id', 'name'])->from('users')->where(['active' => 1])], 'EXISTS (SELECT 1 FROM (SELECT [[id]], [[name]] FROM [[users]] WHERE [[active]]=:qp0) AS a WHERE a.[[id]] = [[id AND a.]]name[[ = ]]name`)', [':qp0' => 1] ], | ||
| //[ ['not in', ['id', 'name'], (new Query())->select(['id', 'name'])->from('users')->where(['active' => 1])], 'NOT EXISTS (SELECT 1 FROM (SELECT [[id]], [[name]] FROM [[users]] WHERE [[active]]=:qp0) AS a WHERE a.[[id]] = [[id]] AND a.[[name = ]]name`)', [':qp0' => 1] ], | ||
| 'composite in' => [ | ||
| [ | ||
| 'in', | ||
| ['id', 'name'], | ||
| [['id' => 1, 'name' => 'oy']], | ||
| ], | ||
| '(([id] = :qp0 AND [name] = :qp1))', | ||
| [':qp0' => 1, ':qp1' => 'oy'], | ||
| ], | ||
| 'composite in using array objects' => [ | ||
| [ | ||
| 'in', | ||
| new TraversableObject(['id', 'name']), | ||
| new TraversableObject([['id' => 1, 'name' => 'oy'], ['id' => 2, 'name' => 'yo']]) | ||
| ], | ||
| '(([id] = :qp0 AND [name] = :qp1) OR ([id] = :qp2 AND [name] = :qp3))', | ||
| [':qp0' => 1, ':qp1' => 'oy', ':qp2' => 2, ':qp3' => 'yo'], | ||
| ], | ||
| ], | ||
| ); | ||
| $data['composite in'] = [ | ||
| ['in', ['id', 'name'], [['id' => 1, 'name' => 'oy']]], | ||
| '(([id] = :qp0 AND [name] = :qp1))', | ||
| [':qp0' => 1, ':qp1' => 'oy'], | ||
| ]; | ||
| $data['composite in using array objects'] = [ | ||
| ['in', new TraversableObject(['id', 'name']), new TraversableObject([ | ||
| ['id' => 1, 'name' => 'oy'], | ||
| ['id' => 2, 'name' => 'yo'], | ||
| ])], | ||
| '(([id] = :qp0 AND [name] = :qp1) OR ([id] = :qp2 AND [name] = :qp3))', | ||
| [':qp0' => 1, ':qp1' => 'oy', ':qp2' => 2, ':qp3' => 'yo'], | ||
| ]; | ||
|
|
||
| // adjust dbms specific escaping | ||
| foreach ($data as $i => $condition) { | ||
| $data[$i][1] = DbHelper::replaceQuotes($condition[1], 'sqlsrv'); | ||
| } | ||
|
|
||
| return $data; | ||
| } | ||
|
|
||
| public function testAlterColumn(): void | ||
|
|
@@ -845,7 +843,7 @@ public function testDropColumnOnDb(): void | |
| $this->assertEquals(null, $schema->getColumn('bar')); | ||
| } | ||
|
|
||
| public function buildFromDataProvider() | ||
| public static function buildFromDataProvider(): array | ||
| { | ||
| $data = parent::buildFromDataProvider(); | ||
| $data[] = ['[test]', '[[test]]']; | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.