diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index 456fefa1ff..9442b55f87 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -4,9 +4,9 @@ Yii Framework 2 Change Log 2.0.23 under development ------------------------ -- Bug #17413, #17418: Fixed MSSQL tests (alexkart) -- Bug #17413: Fixed MSSQL tests: `QueryBuilderTest::testGetColumnType()`, `QueryBuilderTest::testResetSequence()` (alexkart) +- Bug #17413, #17418, #17426, #17431: Fixed MSSQL tests (alexkart) - Bug #17420: Fixed loading of column default values for MSSQL (alexkart) +- Bug #17395: Fixed issues with actions that contain underscores in their names (alexkart) 2.0.22 July 02, 2019 @@ -20,7 +20,6 @@ Yii Framework 2 Change Log - Bug #17389: Fixed `UniqueValidator` to work with Active Record having `joinWith()` in its `find()` (garthpmurray) - Enh #17382: Added `\yii\validators\DateValidator::$strictDateFormat` to enable strict validation (alexkart) - Enh #17396: Added 'invoked by controller' to the debug log message when `\yii\base\Action` is used (alexkart) -- Bug #17395: Fixed issues with actions that contain underscores in their names (alexkart) 2.0.21 June 18, 2019 diff --git a/tests/data/mssql.sql b/tests/data/mssql.sql index ce8f7343e5..7c95a8ad48 100644 --- a/tests/data/mssql.sql +++ b/tests/data/mssql.sql @@ -331,3 +331,34 @@ CREATE TABLE [T_upsert] CREATE TABLE [dbo].[table.with.special.characters] ( [id] [int] ); + +IF OBJECT_ID('[validator_main]', 'U') IS NOT NULL DROP TABLE [dbo].[validator_main]; +IF OBJECT_ID('[validator_ref]', 'U') IS NOT NULL DROP TABLE [dbo].[validator_ref]; + +create table [dbo].[validator_main] +( + id int identity + constraint validator_main_pk + primary key nonclustered, + field1 nvarchar(255) +); + +create table [dbo].[validator_ref] +( + id int identity + constraint validator_ref_pk + primary key nonclustered, + a_field nvarchar(255), + ref int +); + +INSERT INTO [validator_main] (field1) VALUES ('just a string1'); +INSERT INTO [validator_main] (field1) VALUES ('just a string2'); +INSERT INTO [validator_main] (field1) VALUES ('just a string3'); +INSERT INTO [validator_main] (field1) VALUES ('just a string4'); +INSERT INTO [validator_ref] (a_field, ref) VALUES ('ref_to_2', 2); +INSERT INTO [validator_ref] (a_field, ref) VALUES ('ref_to_2', 2); +INSERT INTO [validator_ref] (a_field, ref) VALUES ('ref_to_3', 3); +INSERT INTO [validator_ref] (a_field, ref) VALUES ('ref_to_4', 4); +INSERT INTO [validator_ref] (a_field, ref) VALUES ('ref_to_4', 4); +INSERT INTO [validator_ref] (a_field, ref) VALUES ('ref_to_5', 5); diff --git a/tests/data/postgres.sql b/tests/data/postgres.sql index c2bd8c519e..bc61454811 100644 --- a/tests/data/postgres.sql +++ b/tests/data/postgres.sql @@ -309,11 +309,11 @@ DROP TABLE IF EXISTS "validatorMain" CASCADE; DROP TABLE IF EXISTS "validatorRef" CASCADE; CREATE TABLE "validator_main" ( - id integer not null primary key, + id serial primary key, field1 VARCHAR(255) ); CREATE TABLE "validator_ref" ( - id integer not null primary key, + id serial primary key, a_field VARCHAR(255), ref integer ); @@ -328,16 +328,16 @@ CREATE TABLE "validatorRef" ( CONSTRAINT "validatorRef_id" FOREIGN KEY ("ref") REFERENCES "validatorMain" ("id") ON DELETE CASCADE ON UPDATE CASCADE ); -INSERT INTO "validator_main" (id, field1) VALUES (1, 'just a string1'); -INSERT INTO "validator_main" (id, field1) VALUES (2, 'just a string2'); -INSERT INTO "validator_main" (id, field1) VALUES (3, 'just a string3'); -INSERT INTO "validator_main" (id, field1) VALUES (4, 'just a string4'); -INSERT INTO "validator_ref" (id, a_field, ref) VALUES (1, 'ref_to_2', 2); -INSERT INTO "validator_ref" (id, a_field, ref) VALUES (2, 'ref_to_2', 2); -INSERT INTO "validator_ref" (id, a_field, ref) VALUES (3, 'ref_to_3', 3); -INSERT INTO "validator_ref" (id, a_field, ref) VALUES (4, 'ref_to_4', 4); -INSERT INTO "validator_ref" (id, a_field, ref) VALUES (5, 'ref_to_4', 4); -INSERT INTO "validator_ref" (id, a_field, ref) VALUES (6, 'ref_to_5', 5); +INSERT INTO "validator_main" (field1) VALUES ('just a string1'); +INSERT INTO "validator_main" (field1) VALUES ('just a string2'); +INSERT INTO "validator_main" (field1) VALUES ('just a string3'); +INSERT INTO "validator_main" (field1) VALUES ('just a string4'); +INSERT INTO "validator_ref" (a_field, ref) VALUES ('ref_to_2', 2); +INSERT INTO "validator_ref" (a_field, ref) VALUES ('ref_to_2', 2); +INSERT INTO "validator_ref" (a_field, ref) VALUES ('ref_to_3', 3); +INSERT INTO "validator_ref" (a_field, ref) VALUES ('ref_to_4', 4); +INSERT INTO "validator_ref" (a_field, ref) VALUES ('ref_to_4', 4); +INSERT INTO "validator_ref" (a_field, ref) VALUES ('ref_to_5', 5); INSERT INTO "validatorMain" (id, field1) VALUES (2, 'just a string2'); INSERT INTO "validatorMain" (id, field1) VALUES (3, 'just a string3'); INSERT INTO "validatorRef" (id, a_field, ref) VALUES (1, 'ref_to_2', 2); diff --git a/tests/framework/db/mssql/QueryBuilderTest.php b/tests/framework/db/mssql/QueryBuilderTest.php index 802a281b6b..397f5a9321 100644 --- a/tests/framework/db/mssql/QueryBuilderTest.php +++ b/tests/framework/db/mssql/QueryBuilderTest.php @@ -70,6 +70,7 @@ class QueryBuilderTest extends \yiiunit\framework\db\QueryBuilderTest public function testCommentColumn() { + // related to https://github.com/yiisoft/yii2/pull/17364 $this->markTestSkipped('Should be fixed'); $qb = $this->getQueryBuilder(); @@ -85,9 +86,8 @@ class QueryBuilderTest extends \yiiunit\framework\db\QueryBuilderTest public function testCommentTable() { - if ($this->driverName === 'sqlsrv') { - $this->markTestSkipped('Should be fixed'); - } + // related to https://github.com/yiisoft/yii2/pull/17364 + $this->markTestSkipped('Should be fixed'); $qb = $this->getQueryBuilder(); diff --git a/tests/framework/validators/ExistValidatorTest.php b/tests/framework/validators/ExistValidatorTest.php index 1e1b140b6d..d55097ed4b 100644 --- a/tests/framework/validators/ExistValidatorTest.php +++ b/tests/framework/validators/ExistValidatorTest.php @@ -50,10 +50,6 @@ abstract class ExistValidatorTest extends DatabaseTestCase public function testValidateValue() { - if ($this->driverName === 'sqlsrv') { - $this->markTestSkipped('Should be fixed'); - } - $val = new ExistValidator(['targetClass' => ValidatorTestRefModel::className(), 'targetAttribute' => 'id']); $this->assertTrue($val->validate(2)); $this->assertTrue($val->validate(5)); @@ -63,10 +59,6 @@ abstract class ExistValidatorTest extends DatabaseTestCase public function testValidateAttribute() { - if ($this->driverName === 'sqlsrv') { - $this->markTestSkipped('Should be fixed'); - } - // existing value on different table $val = new ExistValidator(['targetClass' => ValidatorTestMainModel::className(), 'targetAttribute' => 'id']); $m = ValidatorTestRefModel::findOne(['id' => 1]); @@ -216,10 +208,6 @@ abstract class ExistValidatorTest extends DatabaseTestCase public function testTargetRelation() { - if ($this->driverName === 'sqlsrv') { - $this->markTestSkipped('Should be fixed'); - } - $val = new ExistValidator(['targetRelation' => 'references']); $m = ValidatorTestMainModel::findOne(2); @@ -233,10 +221,6 @@ abstract class ExistValidatorTest extends DatabaseTestCase public function testTargetRelationWithFilter() { - if ($this->driverName === 'sqlsrv') { - $this->markTestSkipped('Should be fixed'); - } - $val = new ExistValidator(['targetRelation' => 'references', 'filter' => function ($query) { $query->andWhere(['a_field' => 'ref_to_2']); }]); @@ -254,10 +238,6 @@ abstract class ExistValidatorTest extends DatabaseTestCase public function testForceMaster() { - if ($this->driverName === 'sqlsrv') { - $this->markTestSkipped('Should be fixed'); - } - $connection = $this->getConnectionWithInvalidSlave(); ActiveRecord::$db = $connection; diff --git a/tests/framework/validators/UniqueValidatorTest.php b/tests/framework/validators/UniqueValidatorTest.php index 148cdbf893..ea673e2906 100644 --- a/tests/framework/validators/UniqueValidatorTest.php +++ b/tests/framework/validators/UniqueValidatorTest.php @@ -95,10 +95,6 @@ abstract class UniqueValidatorTest extends DatabaseTestCase public function testValidateAttributeDefault() { - if ($this->driverName === 'sqlsrv') { - $this->markTestSkipped('Should be fixed'); - } - $val = new UniqueValidator(); $m = ValidatorTestMainModel::find()->one(); $val->validateAttribute($m, 'id'); @@ -113,7 +109,6 @@ abstract class UniqueValidatorTest extends DatabaseTestCase $val->validateAttribute($m, 'ref'); $this->assertTrue($m->hasErrors('ref')); $m = new ValidatorTestRefModel(); - $m->id = 7; $m->ref = 12121; $val->validateAttribute($m, 'ref'); $this->assertFalse($m->hasErrors('ref')); @@ -128,10 +123,6 @@ abstract class UniqueValidatorTest extends DatabaseTestCase public function testValidateAttributeOfNonARModel() { - if ($this->driverName === 'sqlsrv') { - $this->markTestSkipped('Should be fixed'); - } - $val = new UniqueValidator(['targetClass' => ValidatorTestRefModel::className(), 'targetAttribute' => 'ref']); $m = FakedValidationModel::createWithAttributes(['attr_1' => 5, 'attr_2' => 1313]); $val->validateAttribute($m, 'attr_1'); @@ -142,10 +133,6 @@ abstract class UniqueValidatorTest extends DatabaseTestCase public function testValidateNonDatabaseAttribute() { - if ($this->driverName === 'sqlsrv') { - $this->markTestSkipped('Should be fixed'); - } - $val = new UniqueValidator(['targetClass' => ValidatorTestRefModel::className(), 'targetAttribute' => 'ref']); /** @var ValidatorTestMainModel $m */ $m = ValidatorTestMainModel::findOne(1); @@ -221,14 +208,10 @@ abstract class UniqueValidatorTest extends DatabaseTestCase public function testValidateTargetClass() { - if ($this->driverName === 'sqlsrv') { - $this->markTestSkipped('Should be fixed'); - } - - // Check whether "Description" and "address" aren't equal + // Check whether "Description" and "name" aren't equal $val = new UniqueValidator([ 'targetClass' => Customer::className(), - 'targetAttribute' => ['description' => 'address'], + 'targetAttribute' => ['description' => 'name'], ]); /** @var Profile $m */ @@ -238,16 +221,16 @@ abstract class UniqueValidatorTest extends DatabaseTestCase $this->assertFalse($m->hasErrors('description')); // ID of Profile is not equal to ID of Customer - // (1, description = address2) <=> (2, address = address2) - $m->description = 'address2'; + // (1, description = user2) <=> (2, name = user2) + $m->description = 'user2'; $val->validateAttribute($m, 'description'); $this->assertTrue($m->hasErrors('description')); $m->clearErrors('description'); // ID of Profile IS equal to ID of Customer - // (1, description = address1) <=> (1, address = address1) + // (1, description = user1) <=> (1, name = user1) // https://github.com/yiisoft/yii2/issues/10263 - $m->description = 'address1'; + $m->description = 'user1'; $val->validateAttribute($m, 'description'); $this->assertTrue($m->hasErrors('description')); } @@ -294,44 +277,32 @@ abstract class UniqueValidatorTest extends DatabaseTestCase public function testValidateEmptyAttributeInStringField() { - if ($this->driverName === 'sqlsrv') { - $this->markTestSkipped('Should be fixed'); - } - ValidatorTestMainModel::deleteAll(); $val = new UniqueValidator(); $m = new ValidatorTestMainModel(['field1' => '']); - $m->id = 1; $val->validateAttribute($m, 'field1'); $this->assertFalse($m->hasErrors('field1')); $m->save(false); $m = new ValidatorTestMainModel(['field1' => '']); - $m->id = 2; $val->validateAttribute($m, 'field1'); $this->assertTrue($m->hasErrors('field1')); } public function testValidateEmptyAttributeInIntField() { - if ($this->driverName === 'sqlsrv') { - $this->markTestSkipped('Should be fixed'); - } - ValidatorTestRefModel::deleteAll(); $val = new UniqueValidator(); $m = new ValidatorTestRefModel(['ref' => 0]); - $m->id = 1; $val->validateAttribute($m, 'ref'); $this->assertFalse($m->hasErrors('ref')); $m->save(false); $m = new ValidatorTestRefModel(['ref' => 0]); - $m->id = 2; $val->validateAttribute($m, 'ref'); $this->assertTrue($m->hasErrors('ref')); } @@ -424,17 +395,12 @@ abstract class UniqueValidatorTest extends DatabaseTestCase */ public function testAmbiguousColumnName() { - if ($this->driverName === 'sqlsrv') { - $this->markTestSkipped('Should be fixed'); - } - $validator = new UniqueValidator([ 'filter' => function ($query) { $query->joinWith('items', false); }, ]); $model = new Order(); - $model->id = 42; $model->customer_id = 1; $model->total = 800; $model->save(false); @@ -448,17 +414,12 @@ abstract class UniqueValidatorTest extends DatabaseTestCase */ public function testExpressionInAttributeColumnName() { - if ($this->driverName === 'sqlsrv') { - $this->markTestSkipped('Should be fixed'); - } - $validator = new UniqueValidator([ 'targetAttribute' => [ 'title' => 'LOWER(title)', ], ]); $model = new Document(); - $model->id = 42; $model->title = 'Test'; $model->content = 'test'; $model->version = 1;