diff --git a/tests/unit/TestCase.php b/tests/unit/TestCase.php index 787b1e0..eaa3b28 100644 --- a/tests/unit/TestCase.php +++ b/tests/unit/TestCase.php @@ -1,6 +1,7 @@ <?php namespace yiiunit; + use yii\helpers\ArrayHelper; /** diff --git a/tests/unit/data/ar/Customer.php b/tests/unit/data/ar/Customer.php index bac3850..59a7e88 100644 --- a/tests/unit/data/ar/Customer.php +++ b/tests/unit/data/ar/Customer.php @@ -48,7 +48,7 @@ class Customer extends ActiveRecord { /** @var ActiveQuery $rel */ $rel = $this->hasMany(Item::className(), ['id' => 'item_id']); - return $rel->viaTable('tbl_order_item', ['order_id' => 'id'], function($q) { + return $rel->viaTable('tbl_order_item', ['order_id' => 'id'], function ($q) { /** @var ActiveQuery $q */ $q->viaTable('tbl_order', ['customer_id' => 'id']); })->orderBy('id'); diff --git a/tests/unit/data/ar/CustomerQuery.php b/tests/unit/data/ar/CustomerQuery.php index 6b10134..c7086e0 100644 --- a/tests/unit/data/ar/CustomerQuery.php +++ b/tests/unit/data/ar/CustomerQuery.php @@ -1,5 +1,7 @@ <?php + namespace yiiunit\data\ar; + use yii\db\ActiveQuery; /** @@ -13,4 +15,3 @@ class CustomerQuery extends ActiveQuery return $this; } } - \ No newline at end of file diff --git a/tests/unit/data/ar/Profile.php b/tests/unit/data/ar/Profile.php index 7651d88..3274f2d 100644 --- a/tests/unit/data/ar/Profile.php +++ b/tests/unit/data/ar/Profile.php @@ -18,5 +18,4 @@ class Profile extends ActiveRecord { return 'tbl_profile'; } - -} \ No newline at end of file +} diff --git a/tests/unit/data/ar/elasticsearch/CustomerQuery.php b/tests/unit/data/ar/elasticsearch/CustomerQuery.php index 108466f..0da5305 100644 --- a/tests/unit/data/ar/elasticsearch/CustomerQuery.php +++ b/tests/unit/data/ar/elasticsearch/CustomerQuery.php @@ -1,5 +1,7 @@ <?php + namespace yiiunit\data\ar\elasticsearch; + use yii\elasticsearch\ActiveQuery; /** @@ -13,4 +15,3 @@ class CustomerQuery extends ActiveQuery return $this; } } - \ No newline at end of file diff --git a/tests/unit/data/ar/elasticsearch/Item.php b/tests/unit/data/ar/elasticsearch/Item.php index 033c38d..2baf62f 100644 --- a/tests/unit/data/ar/elasticsearch/Item.php +++ b/tests/unit/data/ar/elasticsearch/Item.php @@ -1,6 +1,7 @@ <?php namespace yiiunit\data\ar\elasticsearch; + use yii\elasticsearch\Command; /** diff --git a/tests/unit/data/ar/elasticsearch/Order.php b/tests/unit/data/ar/elasticsearch/Order.php index 8a52c9f..1bf76bb 100644 --- a/tests/unit/data/ar/elasticsearch/Order.php +++ b/tests/unit/data/ar/elasticsearch/Order.php @@ -1,6 +1,7 @@ <?php namespace yiiunit\data\ar\elasticsearch; + use yii\elasticsearch\Command; /** diff --git a/tests/unit/data/ar/elasticsearch/OrderItem.php b/tests/unit/data/ar/elasticsearch/OrderItem.php index 36961d9..b8cdf40 100644 --- a/tests/unit/data/ar/elasticsearch/OrderItem.php +++ b/tests/unit/data/ar/elasticsearch/OrderItem.php @@ -1,6 +1,7 @@ <?php namespace yiiunit\data\ar\elasticsearch; + use yii\elasticsearch\Command; /** diff --git a/tests/unit/data/ar/mongodb/ActiveRecord.php b/tests/unit/data/ar/mongodb/ActiveRecord.php index b0709a8..47b4cd9 100644 --- a/tests/unit/data/ar/mongodb/ActiveRecord.php +++ b/tests/unit/data/ar/mongodb/ActiveRecord.php @@ -13,4 +13,4 @@ class ActiveRecord extends \yii\mongodb\ActiveRecord { return self::$db; } -} \ No newline at end of file +} diff --git a/tests/unit/data/ar/mongodb/Customer.php b/tests/unit/data/ar/mongodb/Customer.php index c32354c..8fa2a23 100644 --- a/tests/unit/data/ar/mongodb/Customer.php +++ b/tests/unit/data/ar/mongodb/Customer.php @@ -30,4 +30,4 @@ class Customer extends ActiveRecord $config['modelClass'] = get_called_class(); return new CustomerQuery($config); } -} \ No newline at end of file +} diff --git a/tests/unit/data/ar/mongodb/CustomerOrder.php b/tests/unit/data/ar/mongodb/CustomerOrder.php index f037aae..ecac666 100644 --- a/tests/unit/data/ar/mongodb/CustomerOrder.php +++ b/tests/unit/data/ar/mongodb/CustomerOrder.php @@ -24,4 +24,4 @@ class CustomerOrder extends ActiveRecord { return $this->hasOne(Customer::className(), ['_id' => 'customer_id']); } -} \ No newline at end of file +} diff --git a/tests/unit/data/ar/mongodb/CustomerQuery.php b/tests/unit/data/ar/mongodb/CustomerQuery.php index bf222b6..3b2d93d 100644 --- a/tests/unit/data/ar/mongodb/CustomerQuery.php +++ b/tests/unit/data/ar/mongodb/CustomerQuery.php @@ -1,5 +1,7 @@ <?php + namespace yiiunit\data\ar\mongodb; + use yii\mongodb\ActiveQuery; /** @@ -13,4 +15,3 @@ class CustomerQuery extends ActiveQuery return $this; } } - \ No newline at end of file diff --git a/tests/unit/data/ar/mongodb/file/ActiveRecord.php b/tests/unit/data/ar/mongodb/file/ActiveRecord.php index 8ebc1b4..270ba43 100644 --- a/tests/unit/data/ar/mongodb/file/ActiveRecord.php +++ b/tests/unit/data/ar/mongodb/file/ActiveRecord.php @@ -13,4 +13,4 @@ class ActiveRecord extends \yii\mongodb\file\ActiveRecord { return self::$db; } -} \ No newline at end of file +} diff --git a/tests/unit/data/ar/mongodb/file/CustomerFile.php b/tests/unit/data/ar/mongodb/file/CustomerFile.php index 18fabd8..3083ff6 100644 --- a/tests/unit/data/ar/mongodb/file/CustomerFile.php +++ b/tests/unit/data/ar/mongodb/file/CustomerFile.php @@ -25,4 +25,4 @@ class CustomerFile extends ActiveRecord $config['modelClass'] = get_called_class(); return new CustomerFileQuery($config); } -} \ No newline at end of file +} diff --git a/tests/unit/data/ar/mongodb/file/CustomerFileQuery.php b/tests/unit/data/ar/mongodb/file/CustomerFileQuery.php index 6adbe80..f49f644 100644 --- a/tests/unit/data/ar/mongodb/file/CustomerFileQuery.php +++ b/tests/unit/data/ar/mongodb/file/CustomerFileQuery.php @@ -1,5 +1,7 @@ <?php + namespace yiiunit\data\ar\mongodb\file; + use yii\mongodb\file\ActiveQuery; /** @@ -13,4 +15,3 @@ class CustomerFileQuery extends ActiveQuery return $this; } } - \ No newline at end of file diff --git a/tests/unit/data/ar/redis/ActiveRecord.php b/tests/unit/data/ar/redis/ActiveRecord.php index 9d5caf0..121cd89 100644 --- a/tests/unit/data/ar/redis/ActiveRecord.php +++ b/tests/unit/data/ar/redis/ActiveRecord.php @@ -21,4 +21,4 @@ class ActiveRecord extends \yii\redis\ActiveRecord { return self::$db; } -} \ No newline at end of file +} diff --git a/tests/unit/data/ar/redis/CustomerQuery.php b/tests/unit/data/ar/redis/CustomerQuery.php index 47d69fb..4e68d32 100644 --- a/tests/unit/data/ar/redis/CustomerQuery.php +++ b/tests/unit/data/ar/redis/CustomerQuery.php @@ -1,5 +1,7 @@ <?php + namespace yiiunit\data\ar\redis; + use yii\redis\ActiveQuery; /** @@ -13,4 +15,3 @@ class CustomerQuery extends ActiveQuery return $this; } } - \ No newline at end of file diff --git a/tests/unit/data/ar/redis/Item.php b/tests/unit/data/ar/redis/Item.php index 0bcb072..81daa63 100644 --- a/tests/unit/data/ar/redis/Item.php +++ b/tests/unit/data/ar/redis/Item.php @@ -8,4 +8,4 @@ class Item extends ActiveRecord { return ['id', 'name', 'category_id']; } -} \ No newline at end of file +} diff --git a/tests/unit/data/ar/redis/Order.php b/tests/unit/data/ar/redis/Order.php index a9fe64b..2a491ae 100644 --- a/tests/unit/data/ar/redis/Order.php +++ b/tests/unit/data/ar/redis/Order.php @@ -22,7 +22,7 @@ class Order extends ActiveRecord public function getItems() { return $this->hasMany(Item::className(), ['id' => 'item_id']) - ->via('orderItems', function($q) { + ->via('orderItems', function ($q) { // additional query configuration }); } diff --git a/tests/unit/data/ar/redis/OrderItem.php b/tests/unit/data/ar/redis/OrderItem.php index a4c82b9..36a290f 100644 --- a/tests/unit/data/ar/redis/OrderItem.php +++ b/tests/unit/data/ar/redis/OrderItem.php @@ -23,4 +23,4 @@ class OrderItem extends ActiveRecord { return $this->hasOne(Item::className(), ['id' => 'item_id']); } -} \ No newline at end of file +} diff --git a/tests/unit/data/ar/sphinx/ActiveRecord.php b/tests/unit/data/ar/sphinx/ActiveRecord.php index 2e5183e..2df2821 100644 --- a/tests/unit/data/ar/sphinx/ActiveRecord.php +++ b/tests/unit/data/ar/sphinx/ActiveRecord.php @@ -13,4 +13,4 @@ class ActiveRecord extends \yii\sphinx\ActiveRecord { return self::$db; } -} \ No newline at end of file +} diff --git a/tests/unit/data/ar/sphinx/ArticleDb.php b/tests/unit/data/ar/sphinx/ArticleDb.php index 9b4813b..39dc314 100644 --- a/tests/unit/data/ar/sphinx/ArticleDb.php +++ b/tests/unit/data/ar/sphinx/ArticleDb.php @@ -22,4 +22,4 @@ class ArticleDb extends ActiveRecordDb ]; return new ActiveQuery($config); } -} \ No newline at end of file +} diff --git a/tests/unit/data/ar/sphinx/ArticleIndex.php b/tests/unit/data/ar/sphinx/ArticleIndex.php index 27ea274..5f71078 100644 --- a/tests/unit/data/ar/sphinx/ArticleIndex.php +++ b/tests/unit/data/ar/sphinx/ArticleIndex.php @@ -30,4 +30,4 @@ class ArticleIndex extends ActiveRecord $config['modelClass'] = get_called_class(); return new ArticleIndexQuery($config); } -} \ No newline at end of file +} diff --git a/tests/unit/data/ar/sphinx/ArticleIndexQuery.php b/tests/unit/data/ar/sphinx/ArticleIndexQuery.php index f5843f0..e3589d6 100644 --- a/tests/unit/data/ar/sphinx/ArticleIndexQuery.php +++ b/tests/unit/data/ar/sphinx/ArticleIndexQuery.php @@ -1,5 +1,7 @@ <?php + namespace yiiunit\data\ar\sphinx; + use yii\sphinx\ActiveQuery; /** @@ -13,4 +15,3 @@ class ArticleIndexQuery extends ActiveQuery return $this; } } - \ No newline at end of file diff --git a/tests/unit/data/ar/sphinx/ItemDb.php b/tests/unit/data/ar/sphinx/ItemDb.php index 9cf10ad..c2a40e3 100644 --- a/tests/unit/data/ar/sphinx/ItemDb.php +++ b/tests/unit/data/ar/sphinx/ItemDb.php @@ -10,4 +10,4 @@ class ItemDb extends ActiveRecordDb { return 'yii2_test_item'; } -} \ No newline at end of file +} diff --git a/tests/unit/data/ar/sphinx/ItemIndex.php b/tests/unit/data/ar/sphinx/ItemIndex.php index cfb8418..64b4650 100644 --- a/tests/unit/data/ar/sphinx/ItemIndex.php +++ b/tests/unit/data/ar/sphinx/ItemIndex.php @@ -8,4 +8,4 @@ class ItemIndex extends ActiveRecord { return 'yii2_test_item_index'; } -} \ No newline at end of file +} diff --git a/tests/unit/data/ar/sphinx/RuntimeIndex.php b/tests/unit/data/ar/sphinx/RuntimeIndex.php index 812f27b..0a725e3 100644 --- a/tests/unit/data/ar/sphinx/RuntimeIndex.php +++ b/tests/unit/data/ar/sphinx/RuntimeIndex.php @@ -8,4 +8,4 @@ class RuntimeIndex extends ActiveRecord { return 'yii2_test_rt_index'; } -} \ No newline at end of file +} diff --git a/tests/unit/data/ar/sphinx/TagDb.php b/tests/unit/data/ar/sphinx/TagDb.php index c70030b..126e54b 100644 --- a/tests/unit/data/ar/sphinx/TagDb.php +++ b/tests/unit/data/ar/sphinx/TagDb.php @@ -9,4 +9,4 @@ class TagDb extends ActiveRecordDb { return 'yii2_test_tag'; } -} \ No newline at end of file +} diff --git a/tests/unit/data/i18n/messages/de-DE/test.php b/tests/unit/data/i18n/messages/de-DE/test.php index d8c5290..7cb3ede 100644 --- a/tests/unit/data/i18n/messages/de-DE/test.php +++ b/tests/unit/data/i18n/messages/de-DE/test.php @@ -6,4 +6,4 @@ return [ 'The dog runs fast.' => 'Der Hund rennt schnell.', 'His speed is about {n} km/h.' => 'Seine Geschwindigkeit beträgt {n} km/h.', 'His name is {name} and his speed is about {n, number} km/h.' => 'Er heißt {name} und ist {n, number} km/h schnell.', -]; \ No newline at end of file +]; diff --git a/tests/unit/data/i18n/messages/de/test.php b/tests/unit/data/i18n/messages/de/test.php index f2d6418..9a8684c 100644 --- a/tests/unit/data/i18n/messages/de/test.php +++ b/tests/unit/data/i18n/messages/de/test.php @@ -4,4 +4,4 @@ */ return [ 'Hello world!' => 'Hallo Welt!', -]; \ No newline at end of file +]; diff --git a/tests/unit/data/i18n/messages/en-US/test.php b/tests/unit/data/i18n/messages/en-US/test.php index 83342b0..1f61a9b 100644 --- a/tests/unit/data/i18n/messages/en-US/test.php +++ b/tests/unit/data/i18n/messages/en-US/test.php @@ -4,4 +4,4 @@ */ return [ 'The dog runs fast.' => 'Der Hund rennt schell.', -]; \ No newline at end of file +]; diff --git a/tests/unit/data/i18n/messages/ru/test.php b/tests/unit/data/i18n/messages/ru/test.php index ca6ad20..6ce40dd 100644 --- a/tests/unit/data/i18n/messages/ru/test.php +++ b/tests/unit/data/i18n/messages/ru/test.php @@ -4,4 +4,4 @@ */ return [ 'The dog runs fast.' => 'Собака бегает быстро.', -]; \ No newline at end of file +]; diff --git a/tests/unit/data/validators/TestValidator.php b/tests/unit/data/validators/TestValidator.php index de6fb07..3bc6520 100644 --- a/tests/unit/data/validators/TestValidator.php +++ b/tests/unit/data/validators/TestValidator.php @@ -41,4 +41,4 @@ class TestValidator extends Validator { $this->_setErrorOnValidateAttribute = true; } -} \ No newline at end of file +} diff --git a/tests/unit/data/validators/models/ValidatorTestMainModel.php b/tests/unit/data/validators/models/ValidatorTestMainModel.php index dd6696d..665fcaa 100644 --- a/tests/unit/data/validators/models/ValidatorTestMainModel.php +++ b/tests/unit/data/validators/models/ValidatorTestMainModel.php @@ -18,4 +18,4 @@ class ValidatorTestMainModel extends ActiveRecord { return $this->hasMany(ValidatorTestRefModel::className(), ['ref' => 'id']); } -} \ No newline at end of file +} diff --git a/tests/unit/data/validators/models/ValidatorTestRefModel.php b/tests/unit/data/validators/models/ValidatorTestRefModel.php index ea86fc7..3cbcf1c 100644 --- a/tests/unit/data/validators/models/ValidatorTestRefModel.php +++ b/tests/unit/data/validators/models/ValidatorTestRefModel.php @@ -20,4 +20,4 @@ class ValidatorTestRefModel extends ActiveRecord { return $this->hasOne(ValidatorTestMainModel::className(), ['id' => 'ref']); } -} \ No newline at end of file +} diff --git a/tests/unit/extensions/authclient/AuthActionTest.php b/tests/unit/extensions/authclient/AuthActionTest.php index 955f643..45da52a 100644 --- a/tests/unit/extensions/authclient/AuthActionTest.php +++ b/tests/unit/extensions/authclient/AuthActionTest.php @@ -65,4 +65,4 @@ class AuthActionTest extends TestCase $this->assertContains($url, $response->content); } -} \ No newline at end of file +} diff --git a/tests/unit/extensions/authclient/BaseClientTest.php b/tests/unit/extensions/authclient/BaseClientTest.php index 462d5c2..3b3c329 100644 --- a/tests/unit/extensions/authclient/BaseClientTest.php +++ b/tests/unit/extensions/authclient/BaseClientTest.php @@ -79,4 +79,4 @@ class BaseClientTest extends TestCase class Client extends BaseClient { -} \ No newline at end of file +} diff --git a/tests/unit/extensions/authclient/CollectionTest.php b/tests/unit/extensions/authclient/CollectionTest.php index 3c7b336..c5a7add 100644 --- a/tests/unit/extensions/authclient/CollectionTest.php +++ b/tests/unit/extensions/authclient/CollectionTest.php @@ -81,4 +81,4 @@ class CollectionTest extends TestCase class TestClient extends BaseClient { -} \ No newline at end of file +} diff --git a/tests/unit/extensions/authclient/OAuth1Test.php b/tests/unit/extensions/authclient/OAuth1Test.php index d378a84..8b95f73 100644 --- a/tests/unit/extensions/authclient/OAuth1Test.php +++ b/tests/unit/extensions/authclient/OAuth1Test.php @@ -100,7 +100,8 @@ class OAuth1Test extends TestCase $this->assertEquals($expectedAuthorizationHeader, $authorizationHeader); } - public function testBuildAuthUrl() { + public function testBuildAuthUrl() + { $oauthClient = new OAuth1(); $authUrl = 'http://test.auth.url'; $oauthClient->authUrl = $authUrl; diff --git a/tests/unit/extensions/authclient/OpenIdTest.php b/tests/unit/extensions/authclient/OpenIdTest.php index 57dd899..0979296 100644 --- a/tests/unit/extensions/authclient/OpenIdTest.php +++ b/tests/unit/extensions/authclient/OpenIdTest.php @@ -58,4 +58,4 @@ class OpenIdTest extends TestCase $this->assertArrayHasKey('ax', $info); $this->assertArrayHasKey('sreg', $info); } -} \ No newline at end of file +} diff --git a/tests/unit/extensions/authclient/TokenTest.php b/tests/unit/extensions/authclient/TokenTest.php index 3787d8a..e173f70 100644 --- a/tests/unit/extensions/authclient/TokenTest.php +++ b/tests/unit/extensions/authclient/TokenTest.php @@ -130,4 +130,4 @@ class TokenTest extends TestCase $oauthToken->createTimestamp = $oauthToken->createTimestamp - ($expireDuration +1); $this->assertFalse($oauthToken->getIsValid(), 'Expired token is valid!'); } -} \ No newline at end of file +} diff --git a/tests/unit/extensions/authclient/signature/BaseMethodTest.php b/tests/unit/extensions/authclient/signature/BaseMethodTest.php index bb91e66..fd645fb 100644 --- a/tests/unit/extensions/authclient/signature/BaseMethodTest.php +++ b/tests/unit/extensions/authclient/signature/BaseMethodTest.php @@ -47,4 +47,4 @@ class BaseMethodTest extends TestCase $generatedSignature = $signatureMethod->generateSignature($baseString, $key); $this->assertTrue($signatureMethod->verify($generatedSignature, $baseString, $key), 'Generated signature is invalid!'); } -} \ No newline at end of file +} diff --git a/tests/unit/extensions/authclient/signature/HmacSha1Test.php b/tests/unit/extensions/authclient/signature/HmacSha1Test.php index 6305e03..8bbc911 100644 --- a/tests/unit/extensions/authclient/signature/HmacSha1Test.php +++ b/tests/unit/extensions/authclient/signature/HmacSha1Test.php @@ -17,4 +17,4 @@ class HmacSha1Test extends TestCase $signature = $signatureMethod->generateSignature($baseString, $key); $this->assertNotEmpty($signature, 'Unable to generate signature!'); } -} \ No newline at end of file +} diff --git a/tests/unit/extensions/authclient/signature/PlainTextTest.php b/tests/unit/extensions/authclient/signature/PlainTextTest.php index c5199a5..80d0030 100644 --- a/tests/unit/extensions/authclient/signature/PlainTextTest.php +++ b/tests/unit/extensions/authclient/signature/PlainTextTest.php @@ -17,4 +17,4 @@ class PlainTextTest extends TestCase $signature = $signatureMethod->generateSignature($baseString, $key); $this->assertNotEmpty($signature, 'Unable to generate signature!'); } -} \ No newline at end of file +} diff --git a/tests/unit/extensions/authclient/signature/RsaSha1Test.php b/tests/unit/extensions/authclient/signature/RsaSha1Test.php index 0848ade..e63ce23 100644 --- a/tests/unit/extensions/authclient/signature/RsaSha1Test.php +++ b/tests/unit/extensions/authclient/signature/RsaSha1Test.php @@ -107,4 +107,4 @@ IyvuagHJR379p4dePwJBAMCkYSATGdhYbeDfySWUro5K0QAvBNj8FuNJQ4rqUxz8 $signatureMethod->publicCertificateFile = $certificateFileName; $this->assertEquals(file_get_contents($certificateFileName), $signatureMethod->getPublicCertificate(), 'Unable to fetch public certificate from file!'); } -} \ No newline at end of file +} diff --git a/tests/unit/extensions/elasticsearch/ActiveRecordTest.php b/tests/unit/extensions/elasticsearch/ActiveRecordTest.php index 9aaf25e..ca3158c 100644 --- a/tests/unit/extensions/elasticsearch/ActiveRecordTest.php +++ b/tests/unit/extensions/elasticsearch/ActiveRecordTest.php @@ -20,15 +20,45 @@ class ActiveRecordTest extends ElasticSearchTestCase { use ActiveRecordTestTrait; - public function callCustomerFind($q = null) { return Customer::find($q); } - public function callOrderFind($q = null) { return Order::find($q); } - public function callOrderItemFind($q = null) { return OrderItem::find($q); } - public function callItemFind($q = null) { return Item::find($q); } + public function callCustomerFind($q = null) + { + return Customer::find($q); + } + + public function callOrderFind($q = null) + { + return Order::find($q); + } + + public function callOrderItemFind($q = null) + { + return OrderItem::find($q); + } - public function getCustomerClass() { return Customer::className(); } - public function getItemClass() { return Item::className(); } - public function getOrderClass() { return Order::className(); } - public function getOrderItemClass() { return OrderItem::className(); } + public function callItemFind($q = null) + { + return Item::find($q); + } + + public function getCustomerClass() + { + return Customer::className(); + } + + public function getItemClass() + { + return Item::className(); + } + + public function getOrderClass() + { + return Order::className(); + } + + public function getOrderItemClass() + { + return OrderItem::className(); + } /** * can be overridden to do things after save() @@ -224,7 +254,7 @@ class ActiveRecordTest extends ElasticSearchTestCase $records = Customer::mget([5]); $this->assertEquals(0, count($records)); - $records = Customer::mget([1,3,5]); + $records = Customer::mget([1, 3, 5]); $this->assertEquals(2, count($records)); $this->assertInstanceOf(Customer::className(), $records[0]); $this->assertInstanceOf(Customer::className(), $records[1]); @@ -501,7 +531,7 @@ class ActiveRecordTest extends ElasticSearchTestCase $customerClass = $this->getCustomerClass(); $afterFindCalls = []; - Event::on(BaseActiveRecord::className(), BaseActiveRecord::EVENT_AFTER_FIND, function($event) use (&$afterFindCalls) { + Event::on(BaseActiveRecord::className(), BaseActiveRecord::EVENT_AFTER_FIND, function ($event) use (&$afterFindCalls) { /** @var BaseActiveRecord $ar */ $ar = $event->sender; $afterFindCalls[] = [get_class($ar), $ar->getIsNewRecord(), $ar->getPrimaryKey(), $ar->isRelationPopulated('orders')]; @@ -523,6 +553,5 @@ class ActiveRecordTest extends ElasticSearchTestCase Event::off(BaseActiveRecord::className(), BaseActiveRecord::EVENT_AFTER_FIND); } - // TODO test AR with not mapped PK } diff --git a/tests/unit/extensions/elasticsearch/ElasticSearchConnectionTest.php b/tests/unit/extensions/elasticsearch/ElasticSearchConnectionTest.php index 60b2428..6d88189 100644 --- a/tests/unit/extensions/elasticsearch/ElasticSearchConnectionTest.php +++ b/tests/unit/extensions/elasticsearch/ElasticSearchConnectionTest.php @@ -24,5 +24,4 @@ class ElasticSearchConnectionTest extends ElasticSearchTestCase $this->assertArrayHasKey('version', reset($connection->nodes)); $this->assertArrayHasKey('http_address', reset($connection->nodes)); } - -} \ No newline at end of file +} diff --git a/tests/unit/extensions/elasticsearch/QueryBuilderTest.php b/tests/unit/extensions/elasticsearch/QueryBuilderTest.php index 9e4db02..c7765a4 100644 --- a/tests/unit/extensions/elasticsearch/QueryBuilderTest.php +++ b/tests/unit/extensions/elasticsearch/QueryBuilderTest.php @@ -74,4 +74,3 @@ class QueryBuilderTest extends ElasticSearchTestCase $this->assertEquals(3, $result['hits']['total']); } } - diff --git a/tests/unit/extensions/imagine/ImageGdTest.php b/tests/unit/extensions/imagine/ImageGdTest.php index 9eaf09e..c3597c5 100644 --- a/tests/unit/extensions/imagine/ImageGdTest.php +++ b/tests/unit/extensions/imagine/ImageGdTest.php @@ -26,5 +26,4 @@ class ImageGdTest extends AbstractImageTest $infos = gd_info(); return isset($infos['FreeType Support']) ? $infos['FreeType Support'] : false; } - } diff --git a/tests/unit/extensions/imagine/ImageGmagickTest.php b/tests/unit/extensions/imagine/ImageGmagickTest.php index cfe6dde..abad509 100644 --- a/tests/unit/extensions/imagine/ImageGmagickTest.php +++ b/tests/unit/extensions/imagine/ImageGmagickTest.php @@ -26,5 +26,4 @@ class ImageGmagickTest extends AbstractImageTest { return true; } - } diff --git a/tests/unit/extensions/imagine/ImageImagickTest.php b/tests/unit/extensions/imagine/ImageImagickTest.php index 51834d6..f971f64 100644 --- a/tests/unit/extensions/imagine/ImageImagickTest.php +++ b/tests/unit/extensions/imagine/ImageImagickTest.php @@ -26,5 +26,4 @@ class ImageImagickTest extends AbstractImageTest { return true; } - } diff --git a/tests/unit/extensions/mongodb/ActiveDataProviderTest.php b/tests/unit/extensions/mongodb/ActiveDataProviderTest.php index 257d3b0..5cf67e1 100644 --- a/tests/unit/extensions/mongodb/ActiveDataProviderTest.php +++ b/tests/unit/extensions/mongodb/ActiveDataProviderTest.php @@ -88,4 +88,4 @@ class ActiveDataProviderTest extends MongoDbTestCase $models = $provider->getModels(); $this->assertEquals(5, count($models)); } -} \ No newline at end of file +} diff --git a/tests/unit/extensions/mongodb/ActiveRecordTest.php b/tests/unit/extensions/mongodb/ActiveRecordTest.php index 2db48ba..f334d9b 100644 --- a/tests/unit/extensions/mongodb/ActiveRecordTest.php +++ b/tests/unit/extensions/mongodb/ActiveRecordTest.php @@ -263,4 +263,4 @@ class ActiveRecordTest extends MongoDbTestCase $this->assertNotEmpty($rowRefreshed); $this->assertEquals(7, $rowRefreshed->status); } -} \ No newline at end of file +} diff --git a/tests/unit/extensions/mongodb/CacheTest.php b/tests/unit/extensions/mongodb/CacheTest.php index 95374ca..ed85e95 100644 --- a/tests/unit/extensions/mongodb/CacheTest.php +++ b/tests/unit/extensions/mongodb/CacheTest.php @@ -132,4 +132,4 @@ class CacheTest extends MongoDbTestCase $this->assertEquals(false, $cache->get($key), 'Expired key value returned!'); } -} \ No newline at end of file +} diff --git a/tests/unit/extensions/mongodb/CollectionTest.php b/tests/unit/extensions/mongodb/CollectionTest.php index 9a0c0b4..4d99796 100644 --- a/tests/unit/extensions/mongodb/CollectionTest.php +++ b/tests/unit/extensions/mongodb/CollectionTest.php @@ -419,4 +419,4 @@ class CollectionTest extends MongoDbTestCase $this->assertNotEmpty($result); $this->assertCount(2, $result); } -} \ No newline at end of file +} diff --git a/tests/unit/extensions/mongodb/ConnectionTest.php b/tests/unit/extensions/mongodb/ConnectionTest.php index 7209752..5acd88d 100644 --- a/tests/unit/extensions/mongodb/ConnectionTest.php +++ b/tests/unit/extensions/mongodb/ConnectionTest.php @@ -116,4 +116,4 @@ class ConnectionTest extends MongoDbTestCase $collection2 = $connection->getFileCollection('testfs', true); $this->assertFalse($collection === $collection2); } -} \ No newline at end of file +} diff --git a/tests/unit/extensions/mongodb/DatabaseTest.php b/tests/unit/extensions/mongodb/DatabaseTest.php index c5ed358..f448be0 100644 --- a/tests/unit/extensions/mongodb/DatabaseTest.php +++ b/tests/unit/extensions/mongodb/DatabaseTest.php @@ -67,4 +67,4 @@ class DatabaseTest extends MongoDbTestCase $collection = $database->createCollection('customer'); $this->assertTrue($collection instanceof \MongoCollection); } -} \ No newline at end of file +} diff --git a/tests/unit/extensions/mongodb/QueryRunTest.php b/tests/unit/extensions/mongodb/QueryRunTest.php index e9255a7..79c0461 100644 --- a/tests/unit/extensions/mongodb/QueryRunTest.php +++ b/tests/unit/extensions/mongodb/QueryRunTest.php @@ -141,4 +141,4 @@ class QueryRunTest extends MongoDbTestCase $this->assertEquals('name1', $rows[0]['name']); $this->assertEquals('name10', $rows[1]['name']); } -} \ No newline at end of file +} diff --git a/tests/unit/extensions/mongodb/QueryTest.php b/tests/unit/extensions/mongodb/QueryTest.php index 52b993c..eea5792 100644 --- a/tests/unit/extensions/mongodb/QueryTest.php +++ b/tests/unit/extensions/mongodb/QueryTest.php @@ -94,4 +94,4 @@ class QueryTest extends MongoDbTestCase $this->assertEquals(10, $query->limit); $this->assertEquals(5, $query->offset); } -} \ No newline at end of file +} diff --git a/tests/unit/extensions/mongodb/SessionTest.php b/tests/unit/extensions/mongodb/SessionTest.php index ac0d49a..ccf9fda 100644 --- a/tests/unit/extensions/mongodb/SessionTest.php +++ b/tests/unit/extensions/mongodb/SessionTest.php @@ -137,4 +137,4 @@ class SessionTest extends MongoDbTestCase $rows = $this->findAll($collection); $this->assertCount(1, $rows, 'Wrong records count!'); } -} \ No newline at end of file +} diff --git a/tests/unit/extensions/mongodb/file/ActiveRecordTest.php b/tests/unit/extensions/mongodb/file/ActiveRecordTest.php index 0c4292e..619cc93 100644 --- a/tests/unit/extensions/mongodb/file/ActiveRecordTest.php +++ b/tests/unit/extensions/mongodb/file/ActiveRecordTest.php @@ -320,4 +320,4 @@ class ActiveRecordTest extends MongoDbTestCase fclose($fileResource); $this->assertEquals($newFileContent, $contents); } -} \ No newline at end of file +} diff --git a/tests/unit/extensions/mongodb/file/CollectionTest.php b/tests/unit/extensions/mongodb/file/CollectionTest.php index 550225c..dec4c34 100644 --- a/tests/unit/extensions/mongodb/file/CollectionTest.php +++ b/tests/unit/extensions/mongodb/file/CollectionTest.php @@ -95,4 +95,4 @@ class CollectionTest extends MongoDbTestCase $file = $collection->get($id); $this->assertNull($file); } -} \ No newline at end of file +} diff --git a/tests/unit/extensions/mongodb/file/QueryTest.php b/tests/unit/extensions/mongodb/file/QueryTest.php index 1af07fd..774c98f 100644 --- a/tests/unit/extensions/mongodb/file/QueryTest.php +++ b/tests/unit/extensions/mongodb/file/QueryTest.php @@ -67,4 +67,4 @@ class QueryTest extends MongoDbTestCase $file = $rows[0]; $this->assertEquals('name5', $file['filename']); } -} \ No newline at end of file +} diff --git a/tests/unit/extensions/redis/ActiveRecordTest.php b/tests/unit/extensions/redis/ActiveRecordTest.php index a66ef87..ce5bc11 100644 --- a/tests/unit/extensions/redis/ActiveRecordTest.php +++ b/tests/unit/extensions/redis/ActiveRecordTest.php @@ -16,15 +16,45 @@ class ActiveRecordTest extends RedisTestCase { use ActiveRecordTestTrait; - public function callCustomerFind($q = null) { return Customer::find($q); } - public function callOrderFind($q = null) { return Order::find($q); } - public function callOrderItemFind($q = null) { return OrderItem::find($q); } - public function callItemFind($q = null) { return Item::find($q); } + public function callCustomerFind($q = null) + { + return Customer::find($q); + } + + public function callOrderFind($q = null) + { + return Order::find($q); + } + + public function callOrderItemFind($q = null) + { + return OrderItem::find($q); + } + + public function callItemFind($q = null) + { + return Item::find($q); + } - public function getCustomerClass() { return Customer::className(); } - public function getItemClass() { return Item::className(); } - public function getOrderClass() { return Order::className(); } - public function getOrderItemClass() { return OrderItem::className(); } + public function getCustomerClass() + { + return Customer::className(); + } + + public function getItemClass() + { + return Item::className(); + } + + public function getOrderClass() + { + return Order::className(); + } + + public function getOrderItemClass() + { + return OrderItem::className(); + } public function setUp() @@ -207,7 +237,7 @@ class ActiveRecordTest extends RedisTestCase public function testFindColumn() { $this->assertEquals(['user1', 'user2', 'user3'], Customer::find()->column('name')); -// TODO $this->assertEquals(['user3', 'user2', 'user1'], Customer::find()->orderBy(['name' => SORT_DESC])->column('name')); + // TODO $this->assertEquals(['user3', 'user2', 'user1'], Customer::find()->orderBy(['name' => SORT_DESC])->column('name')); } // TODO test serial column incr diff --git a/tests/unit/extensions/redis/RedisCacheTest.php b/tests/unit/extensions/redis/RedisCacheTest.php index d7a230c..3e4e0bf 100644 --- a/tests/unit/extensions/redis/RedisCacheTest.php +++ b/tests/unit/extensions/redis/RedisCacheTest.php @@ -97,5 +97,4 @@ class RedisCacheTest extends CacheTestCase $cache->set($key, $data); $this->assertTrue($cache->get($key) === $data); } - } diff --git a/tests/unit/extensions/smarty/ViewRendererTest.php b/tests/unit/extensions/smarty/ViewRendererTest.php index 992ff63..bdb9491 100644 --- a/tests/unit/extensions/smarty/ViewRendererTest.php +++ b/tests/unit/extensions/smarty/ViewRendererTest.php @@ -67,4 +67,4 @@ class ViewRendererTest extends TestCase 'baseUrl' => '/assets', ]); } -} \ No newline at end of file +} diff --git a/tests/unit/extensions/sphinx/ActiveDataProviderTest.php b/tests/unit/extensions/sphinx/ActiveDataProviderTest.php index dbf8184..3fa8202 100644 --- a/tests/unit/extensions/sphinx/ActiveDataProviderTest.php +++ b/tests/unit/extensions/sphinx/ActiveDataProviderTest.php @@ -63,4 +63,4 @@ class ActiveDataProviderTest extends SphinxTestCase $models = $provider->getModels(); $this->assertEquals(1, count($models)); } -} \ No newline at end of file +} diff --git a/tests/unit/extensions/sphinx/ActiveRecordTest.php b/tests/unit/extensions/sphinx/ActiveRecordTest.php index 4db492f..5ebd974 100644 --- a/tests/unit/extensions/sphinx/ActiveRecordTest.php +++ b/tests/unit/extensions/sphinx/ActiveRecordTest.php @@ -234,4 +234,4 @@ class ActiveRecordTest extends SphinxTestCase $this->assertArrayHasKey('tokenized', $rows[0], 'No tokenized keyword!'); $this->assertArrayHasKey('normalized', $rows[0], 'No normalized keyword!'); } -} \ No newline at end of file +} diff --git a/tests/unit/extensions/sphinx/ColumnSchemaTest.php b/tests/unit/extensions/sphinx/ColumnSchemaTest.php index 7d62c1d..0a5df78 100644 --- a/tests/unit/extensions/sphinx/ColumnSchemaTest.php +++ b/tests/unit/extensions/sphinx/ColumnSchemaTest.php @@ -52,4 +52,4 @@ class ColumnSchemaTest extends SphinxTestCase $columnSchema->phpType = $phpType; $this->assertEquals($expectedResult, $columnSchema->typecast($value)); } -} \ No newline at end of file +} diff --git a/tests/unit/extensions/sphinx/CommandTest.php b/tests/unit/extensions/sphinx/CommandTest.php index b2346ef..294e1bd 100644 --- a/tests/unit/extensions/sphinx/CommandTest.php +++ b/tests/unit/extensions/sphinx/CommandTest.php @@ -222,7 +222,7 @@ class CommandTest extends SphinxTestCase $this->assertEquals(1, count($rows), 'No row inserted!'); $newTypeId = 5; - $command = $db->createCommand()->replace('yii2_test_rt_index',[ + $command = $db->createCommand()->replace('yii2_test_rt_index', [ 'type_id' => $newTypeId, 'category' => [3, 4], 'id' => 1, @@ -272,7 +272,7 @@ class CommandTest extends SphinxTestCase $this->assertEquals(2, count($rows), 'No rows inserted!'); $newTypeId = 5; - $command = $db->createCommand()->replace('yii2_test_rt_index',[ + $command = $db->createCommand()->replace('yii2_test_rt_index', [ 'type_id' => $newTypeId, 'id' => 1, ]); @@ -406,4 +406,4 @@ class CommandTest extends SphinxTestCase $this->assertArrayHasKey('docs', $rows[0], 'No docs!'); $this->assertArrayHasKey('hits', $rows[0], 'No hits!'); } -} \ No newline at end of file +} diff --git a/tests/unit/extensions/sphinx/ConnectionTest.php b/tests/unit/extensions/sphinx/ConnectionTest.php index 803f627..a31b358 100644 --- a/tests/unit/extensions/sphinx/ConnectionTest.php +++ b/tests/unit/extensions/sphinx/ConnectionTest.php @@ -39,4 +39,4 @@ class ConnectionTest extends SphinxTestCase $this->setExpectedException('yii\db\Exception'); $connection->open(); } -} \ No newline at end of file +} diff --git a/tests/unit/extensions/sphinx/QueryTest.php b/tests/unit/extensions/sphinx/QueryTest.php index 1ba61ef..62d76e7 100644 --- a/tests/unit/extensions/sphinx/QueryTest.php +++ b/tests/unit/extensions/sphinx/QueryTest.php @@ -161,7 +161,7 @@ class QueryTest extends SphinxTestCase $match = 'about'; $snippetPrefix = 'snippet#'; - $snippetCallback = function() use ($match, $snippetPrefix) { + $snippetCallback = function () use ($match, $snippetPrefix) { return [ $snippetPrefix . '1: ' . $match, $snippetPrefix . '2: ' . $match, @@ -195,4 +195,4 @@ class QueryTest extends SphinxTestCase ->count('*', $connection); $this->assertEquals(2, $count); } -} \ No newline at end of file +} diff --git a/tests/unit/extensions/sphinx/SchemaTest.php b/tests/unit/extensions/sphinx/SchemaTest.php index a6925b9..0c975b5 100644 --- a/tests/unit/extensions/sphinx/SchemaTest.php +++ b/tests/unit/extensions/sphinx/SchemaTest.php @@ -80,4 +80,4 @@ class SchemaTest extends SphinxTestCase $this->assertEquals('rt', $index->type); $this->assertTrue($index->isRuntime); } -} \ No newline at end of file +} diff --git a/tests/unit/extensions/twig/ViewRendererTest.php b/tests/unit/extensions/twig/ViewRendererTest.php index 88ca9f7..5e8440f 100644 --- a/tests/unit/extensions/twig/ViewRendererTest.php +++ b/tests/unit/extensions/twig/ViewRendererTest.php @@ -71,4 +71,4 @@ class ViewRendererTest extends TestCase 'baseUrl' => '/assets', ]); } -} \ No newline at end of file +} diff --git a/tests/unit/framework/ar/ActiveRecordTestTrait.php b/tests/unit/framework/ar/ActiveRecordTestTrait.php index 8f9f33f..e9010b6 100644 --- a/tests/unit/framework/ar/ActiveRecordTestTrait.php +++ b/tests/unit/framework/ar/ActiveRecordTestTrait.php @@ -356,11 +356,11 @@ trait ActiveRecordTestTrait $this->assertEquals(2, $this->callCustomerFind()->where(['OR', ['name' => 'user1'], ['name' => 'user2']])->count()); $this->assertEquals(2, count($this->callCustomerFind()->where(['OR', ['name' => 'user1'], ['name' => 'user2']])->all())); - $this->assertEquals(2, $this->callCustomerFind()->where(['name' => ['user1','user2']])->count()); - $this->assertEquals(2, count($this->callCustomerFind()->where(['name' => ['user1','user2']])->all())); + $this->assertEquals(2, $this->callCustomerFind()->where(['name' => ['user1', 'user2']])->count()); + $this->assertEquals(2, count($this->callCustomerFind()->where(['name' => ['user1', 'user2']])->all())); - $this->assertEquals(1, $this->callCustomerFind()->where(['AND', ['name' => ['user2','user3']], ['BETWEEN', 'status', 2, 4]])->count()); - $this->assertEquals(1, count($this->callCustomerFind()->where(['AND', ['name' => ['user2','user3']], ['BETWEEN', 'status', 2, 4]])->all())); + $this->assertEquals(1, $this->callCustomerFind()->where(['AND', ['name' => ['user2', 'user3']], ['BETWEEN', 'status', 2, 4]])->count()); + $this->assertEquals(1, count($this->callCustomerFind()->where(['AND', ['name' => ['user2', 'user3']], ['BETWEEN', 'status', 2, 4]])->all())); } public function testFindNullValues() @@ -384,9 +384,9 @@ trait ActiveRecordTestTrait $this->assertTrue($this->callCustomerFind()->where(['name' => 'user1'])->exists()); $this->assertFalse($this->callCustomerFind()->where(['name' => 'user5'])->exists()); - $this->assertTrue($this->callCustomerFind()->where(['id' => [2,3]])->exists()); - $this->assertTrue($this->callCustomerFind()->where(['id' => [2,3]])->offset(1)->exists()); - $this->assertFalse($this->callCustomerFind()->where(['id' => [2,3]])->offset(2)->exists()); + $this->assertTrue($this->callCustomerFind()->where(['id' => [2, 3]])->exists()); + $this->assertTrue($this->callCustomerFind()->where(['id' => [2, 3]])->offset(1)->exists()); + $this->assertFalse($this->callCustomerFind()->where(['id' => [2, 3]])->offset(2)->exists()); } public function testFindLazy() @@ -854,7 +854,7 @@ trait ActiveRecordTestTrait /** @var TestCase|ActiveRecordTestTrait $this */ $afterFindCalls = []; - Event::on(BaseActiveRecord::className(), BaseActiveRecord::EVENT_AFTER_FIND, function($event) use (&$afterFindCalls) { + Event::on(BaseActiveRecord::className(), BaseActiveRecord::EVENT_AFTER_FIND, function ($event) use (&$afterFindCalls) { /** @var BaseActiveRecord $ar */ $ar = $event->sender; $afterFindCalls[] = [get_class($ar), $ar->getIsNewRecord(), $ar->getPrimaryKey(), $ar->isRelationPopulated('orders')]; diff --git a/tests/unit/framework/base/BehaviorTest.php b/tests/unit/framework/base/BehaviorTest.php index 9e1d0a5..bfcbed0 100644 --- a/tests/unit/framework/base/BehaviorTest.php +++ b/tests/unit/framework/base/BehaviorTest.php @@ -102,5 +102,4 @@ class BehaviorTest extends TestCase $bar->attachBehavior('bar', $behavior); $bar->nomagicBehaviorMethod(); } - } diff --git a/tests/unit/framework/base/EventTest.php b/tests/unit/framework/base/EventTest.php index 6226793..947e454 100644 --- a/tests/unit/framework/base/EventTest.php +++ b/tests/unit/framework/base/EventTest.php @@ -89,5 +89,4 @@ class Post extends ActiveRecord class User extends ActiveRecord { - } diff --git a/tests/unit/framework/db/ActiveRecordTest.php b/tests/unit/framework/db/ActiveRecordTest.php index 6ced6c7..a9c6392 100644 --- a/tests/unit/framework/db/ActiveRecordTest.php +++ b/tests/unit/framework/db/ActiveRecordTest.php @@ -24,15 +24,45 @@ class ActiveRecordTest extends DatabaseTestCase ActiveRecord::$db = $this->getConnection(); } - public function callCustomerFind($q = null) { return Customer::find($q); } - public function callOrderFind($q = null) { return Order::find($q); } - public function callOrderItemFind($q = null) { return OrderItem::find($q); } - public function callItemFind($q = null) { return Item::find($q); } + public function callCustomerFind($q = null) + { + return Customer::find($q); + } + + public function callOrderFind($q = null) + { + return Order::find($q); + } + + public function callOrderItemFind($q = null) + { + return OrderItem::find($q); + } - public function getCustomerClass() { return Customer::className(); } - public function getItemClass() { return Item::className(); } - public function getOrderClass() { return Order::className(); } - public function getOrderItemClass() { return OrderItem::className(); } + public function callItemFind($q = null) + { + return Item::find($q); + } + + public function getCustomerClass() + { + return Customer::className(); + } + + public function getItemClass() + { + return Item::className(); + } + + public function getOrderClass() + { + return Order::className(); + } + + public function getOrderItemClass() + { + return OrderItem::className(); + } public function testCustomColumns() { @@ -284,7 +314,7 @@ class ActiveRecordTest extends DatabaseTestCase $orders = Order::find()->innerJoinWith([ 'customer' => function ($query) { $query->where(['tbl_customer.id' => 2]); - }, + }, ], false)->where(['tbl_order.id' => [1, 2]])->orderBy('tbl_order.id')->all(); $this->assertEquals(1, count($orders)); $this->assertEquals(2, $orders[0]->id); diff --git a/tests/unit/framework/db/QueryBuilderTest.php b/tests/unit/framework/db/QueryBuilderTest.php index c278cc0..4a6b1c1 100644 --- a/tests/unit/framework/db/QueryBuilderTest.php +++ b/tests/unit/framework/db/QueryBuilderTest.php @@ -239,5 +239,4 @@ class QueryBuilderTest extends DatabaseTestCase list($actualQuerySql, $queryParams) = $this->getQueryBuilder()->build($query); $this->assertEquals($expectedQuerySql, $actualQuerySql); }*/ - } diff --git a/tests/unit/framework/db/cubrid/CubridQueryBuilderTest.php b/tests/unit/framework/db/cubrid/CubridQueryBuilderTest.php index 5fe6e45..8693758 100644 --- a/tests/unit/framework/db/cubrid/CubridQueryBuilderTest.php +++ b/tests/unit/framework/db/cubrid/CubridQueryBuilderTest.php @@ -79,5 +79,4 @@ class CubridQueryBuilderTest extends QueryBuilderTest [Schema::TYPE_MONEY . ' NOT NULL', 'decimal(19,4) NOT NULL'], ]; } - } diff --git a/tests/unit/framework/db/mssql/MssqlQueryBuilderTest.php b/tests/unit/framework/db/mssql/MssqlQueryBuilderTest.php index 8337e74..56105ef 100644 --- a/tests/unit/framework/db/mssql/MssqlQueryBuilderTest.php +++ b/tests/unit/framework/db/mssql/MssqlQueryBuilderTest.php @@ -12,49 +12,46 @@ use yii\db\Query; class MSSQLQueryBuilderTest extends QueryBuilderTest { public $driverName = 'sqlsrv'; - - public function testOffsetLimit() { - $expectedQuerySql = 'SELECT `id` FROM `exapmle` OFFSET 5 ROWS FETCH NEXT 10 ROWS ONLY'; - $expectedQueryParams = null; - - $query = new Query(); - $query->select('id') - ->from('example') - ->limit(10)->offset(5); - - list($actualQuerySql, $actualQueryParams) = $this->getQueryBuilder()->build($query); - - $this->assertEquals($expectedQuerySql, $actualQuerySql); - $this->assertEquals($expectedQueryParams, $actualQueryParams); - } - - public function testLimit() { - $expectedQuerySql = 'SELECT `id` FROM `exapmle` OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY'; - $expectedQueryParams = null; - - $query = new Query(); - $query->select('id') - ->from('example') - ->limit(10); - - list($actualQuerySql, $actualQueryParams) = $this->getQueryBuilder()->build($query); - - $this->assertEquals($expectedQuerySql, $actualQuerySql); - $this->assertEquals($expectedQueryParams, $actualQueryParams); - } - - public function testOffset() { - $expectedQuerySql = 'SELECT `id` FROM `exapmle` OFFSET 10 ROWS'; - $expectedQueryParams = null; - - $query = new Query(); - $query->select('id') - ->from('example') - ->offset(10); - - list($actualQuerySql, $actualQueryParams) = $this->getQueryBuilder()->build($query); - - $this->assertEquals($expectedQuerySql, $actualQuerySql); - $this->assertEquals($expectedQueryParams, $actualQueryParams); - } -} \ No newline at end of file + + public function testOffsetLimit() + { + $expectedQuerySql = 'SELECT `id` FROM `exapmle` OFFSET 5 ROWS FETCH NEXT 10 ROWS ONLY'; + $expectedQueryParams = null; + + $query = new Query(); + $query->select('id')->from('example')->limit(10)->offset(5); + + list($actualQuerySql, $actualQueryParams) = $this->getQueryBuilder()->build($query); + + $this->assertEquals($expectedQuerySql, $actualQuerySql); + $this->assertEquals($expectedQueryParams, $actualQueryParams); + } + + public function testLimit() + { + $expectedQuerySql = 'SELECT `id` FROM `exapmle` OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY'; + $expectedQueryParams = null; + + $query = new Query(); + $query->select('id')->from('example')->limit(10); + + list($actualQuerySql, $actualQueryParams) = $this->getQueryBuilder()->build($query); + + $this->assertEquals($expectedQuerySql, $actualQuerySql); + $this->assertEquals($expectedQueryParams, $actualQueryParams); + } + + public function testOffset() + { + $expectedQuerySql = 'SELECT `id` FROM `exapmle` OFFSET 10 ROWS'; + $expectedQueryParams = null; + + $query = new Query(); + $query->select('id')->from('example')->offset(10); + + list($actualQuerySql, $actualQueryParams) = $this->getQueryBuilder()->build($query); + + $this->assertEquals($expectedQuerySql, $actualQuerySql); + $this->assertEquals($expectedQueryParams, $actualQueryParams); + } +} diff --git a/tests/unit/framework/db/sqlite/SqliteQueryBuilderTest.php b/tests/unit/framework/db/sqlite/SqliteQueryBuilderTest.php index 9bf2560..b9d03b8 100644 --- a/tests/unit/framework/db/sqlite/SqliteQueryBuilderTest.php +++ b/tests/unit/framework/db/sqlite/SqliteQueryBuilderTest.php @@ -84,7 +84,7 @@ class SqliteQueryBuilderTest extends QueryBuilderTest public function testBatchInsert() { - $sql = $this->getQueryBuilder()->batchInsert('{{tbl_customer}} t', ['t.id','t.name'], [[1,'a'], [2,'b']]); + $sql = $this->getQueryBuilder()->batchInsert('{{tbl_customer}} t', ['t.id', 't.name'], [[1, 'a'], [2, 'b']]); $this->assertEquals("INSERT INTO {{tbl_customer}} t (`t`.`id`, `t`.`name`) SELECT 1, 'a' UNION ALL 2, 'b'", $sql); } } diff --git a/tests/unit/framework/helpers/FileHelperTest.php b/tests/unit/framework/helpers/FileHelperTest.php index 872e3df..ade18f0 100644 --- a/tests/unit/framework/helpers/FileHelperTest.php +++ b/tests/unit/framework/helpers/FileHelperTest.php @@ -255,16 +255,20 @@ class FileHelperTest extends TestCase { $basePath = $this->testFilePath . DIRECTORY_SEPARATOR; $dirs = ['', 'one', 'one' . DIRECTORY_SEPARATOR . 'two', 'three']; - $files = array_fill_keys(array_map(function($n){return "a.$n";}, range(1,8)), 'file contents'); + $files = array_fill_keys(array_map(function ($n) { + return "a.$n"; + }, range(1, 8)), 'file contents'); $tree = $files; $root = $files; $flat = []; foreach ($dirs as $dir) { foreach ($files as $fileName => $contents) { - $flat[] = rtrim($basePath.$dir,DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.$fileName; + $flat[] = rtrim($basePath . $dir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $fileName; + } + if ($dir === '') { + continue; } - if ($dir === '') continue; $parts = explode(DIRECTORY_SEPARATOR, $dir); $last = array_pop($parts); $parent = array_pop($parts); @@ -280,25 +284,31 @@ class FileHelperTest extends TestCase // range $foundFiles = FileHelper::findFiles($basePath, ['except' => ['a.[2-8]']]); sort($foundFiles); - $expect = array_values(array_filter($flat, function($p){return substr($p, -3)==='a.1';})); + $expect = array_values(array_filter($flat, function ($p) { + return substr($p, -3)==='a.1'; + })); $this->assertEquals($expect, $foundFiles); // suffix $foundFiles = FileHelper::findFiles($basePath, ['except' => ['*.1']]); sort($foundFiles); - $expect = array_values(array_filter($flat, function($p){return substr($p, -3)!=='a.1';})); + $expect = array_values(array_filter($flat, function ($p) { + return substr($p, -3)!=='a.1'; + })); $this->assertEquals($expect, $foundFiles); // dir $foundFiles = FileHelper::findFiles($basePath, ['except' => ['/one']]); sort($foundFiles); - $expect = array_values(array_filter($flat, function($p){return strpos($p, DIRECTORY_SEPARATOR.'one')===false;})); + $expect = array_values(array_filter($flat, function ($p) { + return strpos($p, DIRECTORY_SEPARATOR.'one')===false; + })); $this->assertEquals($expect, $foundFiles); // dir contents $foundFiles = FileHelper::findFiles($basePath, ['except' => ['?*/a.1']]); sort($foundFiles); - $expect = array_values(array_filter($flat, function($p){ + $expect = array_values(array_filter($flat, function ($p) { return substr($p, -11, 10)==='one'.DIRECTORY_SEPARATOR.'two'.DIRECTORY_SEPARATOR.'a.' || ( substr($p, -8)!==DIRECTORY_SEPARATOR.'one'.DIRECTORY_SEPARATOR.'a.1' && substr($p, -10)!==DIRECTORY_SEPARATOR.'three'.DIRECTORY_SEPARATOR.'a.1' diff --git a/tests/unit/framework/helpers/HtmlTest.php b/tests/unit/framework/helpers/HtmlTest.php index 04f3429..d68786d 100644 --- a/tests/unit/framework/helpers/HtmlTest.php +++ b/tests/unit/framework/helpers/HtmlTest.php @@ -213,7 +213,7 @@ class HtmlTest extends TestCase { $this->assertEquals('<input type="radio" name="test" value="1">', Html::radio('test')); $this->assertEquals('<input type="radio" class="a" name="test" checked>', Html::radio('test', true, ['class' => 'a', 'value' => null])); - $this->assertEquals('<input type="hidden" name="test" value="0"><input type="radio" class="a" name="test" value="2" checked>', Html::radio('test', true, ['class' => 'a' , 'uncheck' => '0', 'value' => 2])); + $this->assertEquals('<input type="hidden" name="test" value="0"><input type="radio" class="a" name="test" value="2" checked>', Html::radio('test', true, ['class' => 'a', 'uncheck' => '0', 'value' => 2])); $this->assertEquals('<div class="radio"><label class="bbb"><input type="radio" class="a" name="test" checked> ccc</label></div>', Html::radio('test', true, [ 'class' => 'a', diff --git a/tests/unit/framework/i18n/FallbackMessageFormatterTest.php b/tests/unit/framework/i18n/FallbackMessageFormatterTest.php index bdc4e43..a067f70 100644 --- a/tests/unit/framework/i18n/FallbackMessageFormatterTest.php +++ b/tests/unit/framework/i18n/FallbackMessageFormatterTest.php @@ -97,7 +97,7 @@ _MSG_ [ 'name' => 'Alexander', 'gender' => 'male', - // following should not be replaced + // following should not be replaced 'he' => 'wtf', 'she' => 'wtf', 'it' => 'wtf', diff --git a/tests/unit/framework/i18n/I18NTest.php b/tests/unit/framework/i18n/I18NTest.php index 0f88091..68b0aed 100644 --- a/tests/unit/framework/i18n/I18NTest.php +++ b/tests/unit/framework/i18n/I18NTest.php @@ -105,13 +105,13 @@ class I18NTest extends TestCase $this->assertEquals('Missing translation message.', $this->i18n->translate('test', 'Missing translation message.', [], 'de-DE')); $this->assertEquals('Hallo Welt!', $this->i18n->translate('test', 'Hello world!', [], 'de-DE')); - Event::on(PhpMessageSource::className(), PhpMessageSource::EVENT_MISSING_TRANSLATION, function($event) {}); + Event::on(PhpMessageSource::className(), PhpMessageSource::EVENT_MISSING_TRANSLATION, function ($event) {}); $this->assertEquals('Hallo Welt!', $this->i18n->translate('test', 'Hello world!', [], 'de-DE')); $this->assertEquals('Missing translation message.', $this->i18n->translate('test', 'Missing translation message.', [], 'de-DE')); $this->assertEquals('Hallo Welt!', $this->i18n->translate('test', 'Hello world!', [], 'de-DE')); Event::off(PhpMessageSource::className(), PhpMessageSource::EVENT_MISSING_TRANSLATION); - Event::on(PhpMessageSource::className(), PhpMessageSource::EVENT_MISSING_TRANSLATION, function($event) { + Event::on(PhpMessageSource::className(), PhpMessageSource::EVENT_MISSING_TRANSLATION, function ($event) { if ($event->message == 'New missing translation message.') { $event->translatedMessage = 'TRANSLATION MISSING HERE!'; } @@ -124,4 +124,3 @@ class I18NTest extends TestCase Event::off(PhpMessageSource::className(), PhpMessageSource::EVENT_MISSING_TRANSLATION); } } - diff --git a/tests/unit/framework/log/LoggerTest.php b/tests/unit/framework/log/LoggerTest.php index 97eea7f..9ecb34b 100644 --- a/tests/unit/framework/log/LoggerTest.php +++ b/tests/unit/framework/log/LoggerTest.php @@ -28,4 +28,4 @@ class LoggerTest extends TestCase $this->assertEquals(Logger::LEVEL_ERROR, $logger->messages[1][1]); $this->assertEquals('category', $logger->messages[1][2]); } -} \ No newline at end of file +} diff --git a/tests/unit/framework/log/TargetTest.php b/tests/unit/framework/log/TargetTest.php index 2e1223e..e060665 100644 --- a/tests/unit/framework/log/TargetTest.php +++ b/tests/unit/framework/log/TargetTest.php @@ -85,4 +85,4 @@ class TestTarget extends Target TargetTest::$messages = array_merge(TargetTest::$messages, $this->messages); $this->messages = []; } -} \ No newline at end of file +} diff --git a/tests/unit/framework/mail/BaseMailerTest.php b/tests/unit/framework/mail/BaseMailerTest.php index f22f093..0ed455e 100644 --- a/tests/unit/framework/mail/BaseMailerTest.php +++ b/tests/unit/framework/mail/BaseMailerTest.php @@ -235,12 +235,11 @@ class BaseMailerTest extends TestCase { $message = new Message(); - $mailerMock = $this->getMockBuilder('yiiunit\framework\mail\Mailer')->setMethods(['beforeSend','afterSend'])->getMock(); + $mailerMock = $this->getMockBuilder('yiiunit\framework\mail\Mailer')->setMethods(['beforeSend', 'afterSend'])->getMock(); $mailerMock->expects($this->once())->method('beforeSend')->with($message)->will($this->returnValue(true)); - $mailerMock->expects($this->once())->method('afterSend')->with($message,true); + $mailerMock->expects($this->once())->method('afterSend')->with($message, true); $mailerMock->send($message); } - } /** diff --git a/tests/unit/framework/mail/BaseMessageTest.php b/tests/unit/framework/mail/BaseMessageTest.php index e9ed49e..c69ffbf 100644 --- a/tests/unit/framework/mail/BaseMessageTest.php +++ b/tests/unit/framework/mail/BaseMessageTest.php @@ -78,39 +78,62 @@ class TestMessage extends BaseMessage public $text; public $html; - public function getCharset() {return '';} + public function getCharset() + { + return ''; + } public function setCharset($charset) {} - public function getFrom() {return '';} + public function getFrom() + { + return ''; + } public function setFrom($from) {} - public function getReplyTo() {return '';} + public function getReplyTo() + { + return ''; + } public function setReplyTo($replyTo) {} - public function getTo() {return '';} + public function getTo() + { + return ''; + } public function setTo($to) {} - public function getCc() {return '';} + public function getCc() + { + return ''; + } public function setCc($cc) {} - public function getBcc() {return '';} + public function getBcc() + { + return ''; + } - public function setBcc($bcc) {} + public function setBcc($bcc){} - public function getSubject() {return '';} + public function getSubject() + { + return ''; + } public function setSubject($subject) {} - public function setTextBody($text) { + public function setTextBody($text) + { $this->text = $text; } - public function setHtmlBody($html) { + public function setHtmlBody($html) + { $this->html = $html; } diff --git a/tests/unit/framework/validators/CompareValidatorTest.php b/tests/unit/framework/validators/CompareValidatorTest.php index 8419220..fb2a638 100644 --- a/tests/unit/framework/validators/CompareValidatorTest.php +++ b/tests/unit/framework/validators/CompareValidatorTest.php @@ -6,8 +6,6 @@ use yii\validators\CompareValidator; use yiiunit\data\validators\models\FakedValidationModel; use yiiunit\TestCase; - - class CompareValidatorTest extends TestCase { protected function setUp() diff --git a/tests/unit/framework/validators/DateValidatorTest.php b/tests/unit/framework/validators/DateValidatorTest.php index 98a114f..54ec03c 100644 --- a/tests/unit/framework/validators/DateValidatorTest.php +++ b/tests/unit/framework/validators/DateValidatorTest.php @@ -7,7 +7,6 @@ use yii\validators\DateValidator; use yiiunit\data\validators\models\FakedValidationModel; use yiiunit\TestCase; - class DateValidatorTest extends TestCase { protected function setUp() diff --git a/tests/unit/framework/validators/DefaultValueValidatorTest.php b/tests/unit/framework/validators/DefaultValueValidatorTest.php index 48537d8..fb2bf52 100644 --- a/tests/unit/framework/validators/DefaultValueValidatorTest.php +++ b/tests/unit/framework/validators/DefaultValueValidatorTest.php @@ -1,5 +1,7 @@ <?php + namespace yiiunit\framework\validators; + use yii\validators\DefaultValueValidator; use yiiunit\TestCase; diff --git a/tests/unit/framework/validators/ExistValidatorDriverTests/ExistValidatorPostgresTest.php b/tests/unit/framework/validators/ExistValidatorDriverTests/ExistValidatorPostgresTest.php index 539b458..6ed66af 100644 --- a/tests/unit/framework/validators/ExistValidatorDriverTests/ExistValidatorPostgresTest.php +++ b/tests/unit/framework/validators/ExistValidatorDriverTests/ExistValidatorPostgresTest.php @@ -7,4 +7,4 @@ use yiiunit\framework\validators\ExistValidatorTest; class ExistValidatorPostgresTest extends ExistValidatorTest { protected $driverName = 'pgsql'; -} \ No newline at end of file +} diff --git a/tests/unit/framework/validators/ExistValidatorDriverTests/ExistValidatorSQliteTest.php b/tests/unit/framework/validators/ExistValidatorDriverTests/ExistValidatorSQliteTest.php index cc83fd6..8d8d3d1 100644 --- a/tests/unit/framework/validators/ExistValidatorDriverTests/ExistValidatorSQliteTest.php +++ b/tests/unit/framework/validators/ExistValidatorDriverTests/ExistValidatorSQliteTest.php @@ -7,4 +7,4 @@ use yiiunit\framework\validators\ExistValidatorTest; class ExistValidatorSQliteTest extends ExistValidatorTest { protected $driverName = 'sqlite'; -} \ No newline at end of file +} diff --git a/tests/unit/framework/validators/FilterValidatorTest.php b/tests/unit/framework/validators/FilterValidatorTest.php index b57f649..e224dcd 100644 --- a/tests/unit/framework/validators/FilterValidatorTest.php +++ b/tests/unit/framework/validators/FilterValidatorTest.php @@ -49,4 +49,4 @@ class FilterValidatorTest extends TestCase { return 'not null'; } -} \ No newline at end of file +} diff --git a/tests/unit/framework/validators/NumberValidatorTest.php b/tests/unit/framework/validators/NumberValidatorTest.php index a7fa195..0f3384a 100644 --- a/tests/unit/framework/validators/NumberValidatorTest.php +++ b/tests/unit/framework/validators/NumberValidatorTest.php @@ -144,7 +144,7 @@ class NumberValidatorTest extends TestCase $val->validateAttribute($model, 'attr_number'); $this->assertTrue($model->hasErrors('attr_number')); $val = new NumberValidator(['min' => 1]); - $model = FakedValidationModel::createWithAttributes(['attr_num' => [1,2,3]]); + $model = FakedValidationModel::createWithAttributes(['attr_num' => [1, 2, 3]]); $val->validateAttribute($model, 'attr_num'); $this->assertTrue($model->hasErrors('attr_num')); } diff --git a/tests/unit/framework/validators/RegularExpressionValidatorTest.php b/tests/unit/framework/validators/RegularExpressionValidatorTest.php index 0dd8b04..9905ba5 100644 --- a/tests/unit/framework/validators/RegularExpressionValidatorTest.php +++ b/tests/unit/framework/validators/RegularExpressionValidatorTest.php @@ -50,5 +50,4 @@ class RegularExpressionValidatorTest extends TestCase $val = new RegularExpressionValidator(); $val->validate('abc'); } - } diff --git a/tests/unit/framework/validators/UniqueValidatorDriverTests/UniqueValidatorPostgresTest.php b/tests/unit/framework/validators/UniqueValidatorDriverTests/UniqueValidatorPostgresTest.php index 9adc57c..6b8d100 100644 --- a/tests/unit/framework/validators/UniqueValidatorDriverTests/UniqueValidatorPostgresTest.php +++ b/tests/unit/framework/validators/UniqueValidatorDriverTests/UniqueValidatorPostgresTest.php @@ -8,4 +8,4 @@ use yiiunit\framework\validators\UniqueValidatorTest; class UniqueValidatorPostgresTest extends UniqueValidatorTest { protected $driverName = 'pgsql'; -} \ No newline at end of file +} diff --git a/tests/unit/framework/validators/UniqueValidatorDriverTests/UniqueValidatorSQliteTest.php b/tests/unit/framework/validators/UniqueValidatorDriverTests/UniqueValidatorSQliteTest.php index 9263404..1050677 100644 --- a/tests/unit/framework/validators/UniqueValidatorDriverTests/UniqueValidatorSQliteTest.php +++ b/tests/unit/framework/validators/UniqueValidatorDriverTests/UniqueValidatorSQliteTest.php @@ -8,4 +8,4 @@ use yiiunit\framework\validators\UniqueValidatorTest; class UniqueValidatorSQliteTest extends UniqueValidatorTest { protected $driverName = 'sqlite'; -} \ No newline at end of file +} diff --git a/tests/unit/framework/validators/UrlValidatorTest.php b/tests/unit/framework/validators/UrlValidatorTest.php index 5b2cada..3d99235 100644 --- a/tests/unit/framework/validators/UrlValidatorTest.php +++ b/tests/unit/framework/validators/UrlValidatorTest.php @@ -1,5 +1,7 @@ <?php + namespace yiiunit\framework\validators; + use yiiunit\data\validators\models\FakedValidationModel; use yii\validators\UrlValidator; use yiiunit\TestCase; diff --git a/tests/unit/framework/web/AssetBundleTest.php b/tests/unit/framework/web/AssetBundleTest.php index d989a13..05be603 100644 --- a/tests/unit/framework/web/AssetBundleTest.php +++ b/tests/unit/framework/web/AssetBundleTest.php @@ -253,4 +253,4 @@ class TestAssetCircleB extends AssetBundle public $depends = [ 'yiiunit\\framework\\web\\TestAssetCircleA' ]; -} \ No newline at end of file +} diff --git a/tests/unit/framework/web/AssetConverterTest.php b/tests/unit/framework/web/AssetConverterTest.php index 54669b3..1c857b8 100644 --- a/tests/unit/framework/web/AssetConverterTest.php +++ b/tests/unit/framework/web/AssetConverterTest.php @@ -4,6 +4,7 @@ */ namespace yiiunit\framework\web; + use yii\web\AssetConverter; /** @@ -39,4 +40,4 @@ EOF $this->assertTrue(file_exists($tmpPath . '/test.txt'), 'Failed asserting that asset output file exists.'); $this->assertEquals("Hello World!\nHello Yii!", file_get_contents($tmpPath . '/test.txt')); } -} \ No newline at end of file +}