Browse Source

Merge pull request #2667 from AlexGx/tests-codestyle-fix

Tests codestyle fix
tags/2.0.0-beta
Carsten Brandt 11 years ago
parent
commit
4384a96812
  1. 1
      tests/unit/TestCase.php
  2. 3
      tests/unit/data/ar/CustomerQuery.php
  3. 1
      tests/unit/data/ar/Profile.php
  4. 1
      tests/unit/data/ar/elasticsearch/Customer.php
  5. 3
      tests/unit/data/ar/elasticsearch/CustomerQuery.php
  6. 1
      tests/unit/data/ar/elasticsearch/Item.php
  7. 1
      tests/unit/data/ar/elasticsearch/Order.php
  8. 1
      tests/unit/data/ar/elasticsearch/OrderItem.php
  9. 3
      tests/unit/data/ar/mongodb/CustomerQuery.php
  10. 3
      tests/unit/data/ar/mongodb/file/CustomerFileQuery.php
  11. 3
      tests/unit/data/ar/redis/CustomerQuery.php
  12. 3
      tests/unit/data/ar/sphinx/ArticleIndexQuery.php
  13. 3
      tests/unit/extensions/authclient/OAuth1Test.php
  14. 47
      tests/unit/extensions/elasticsearch/ActiveRecordTest.php
  15. 1
      tests/unit/extensions/elasticsearch/ElasticSearchConnectionTest.php
  16. 1
      tests/unit/extensions/elasticsearch/QueryBuilderTest.php
  17. 1
      tests/unit/extensions/imagine/ImageGdTest.php
  18. 1
      tests/unit/extensions/imagine/ImageGmagickTest.php
  19. 1
      tests/unit/extensions/imagine/ImageImagickTest.php
  20. 48
      tests/unit/extensions/redis/ActiveRecordTest.php
  21. 1
      tests/unit/extensions/redis/RedisCacheTest.php
  22. 1
      tests/unit/framework/base/BehaviorTest.php
  23. 1
      tests/unit/framework/base/EventTest.php
  24. 48
      tests/unit/framework/db/ActiveRecordTest.php
  25. 1
      tests/unit/framework/db/QueryBuilderTest.php
  26. 1
      tests/unit/framework/db/cubrid/CubridQueryBuilderTest.php
  27. 21
      tests/unit/framework/db/mssql/MssqlQueryBuilderTest.php
  28. 20
      tests/unit/framework/helpers/FileHelperTest.php
  29. 1
      tests/unit/framework/i18n/I18NTest.php
  30. 1
      tests/unit/framework/mail/BaseMailerTest.php
  31. 41
      tests/unit/framework/mail/BaseMessageTest.php
  32. 2
      tests/unit/framework/validators/CompareValidatorTest.php
  33. 1
      tests/unit/framework/validators/DateValidatorTest.php
  34. 2
      tests/unit/framework/validators/DefaultValueValidatorTest.php
  35. 1
      tests/unit/framework/validators/RegularExpressionValidatorTest.php
  36. 2
      tests/unit/framework/validators/UrlValidatorTest.php
  37. 1
      tests/unit/framework/web/AssetConverterTest.php

1
tests/unit/TestCase.php

@ -1,6 +1,7 @@
<?php
namespace yiiunit;
use yii\helpers\ArrayHelper;
/**

3
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;
}
}

1
tests/unit/data/ar/Profile.php

@ -18,5 +18,4 @@ class Profile extends ActiveRecord
{
return 'tbl_profile';
}
}

1
tests/unit/data/ar/elasticsearch/Customer.php

@ -45,6 +45,7 @@ class Customer extends ActiveRecord
/**
* sets up the index for this record
* @param Command $command
* @param boolean $statusIsBoolean
*/
public static function setUpMapping($command, $statusIsBoolean = false)
{

3
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;
}
}

1
tests/unit/data/ar/elasticsearch/Item.php

@ -1,6 +1,7 @@
<?php
namespace yiiunit\data\ar\elasticsearch;
use yii\elasticsearch\Command;
/**

1
tests/unit/data/ar/elasticsearch/Order.php

@ -1,6 +1,7 @@
<?php
namespace yiiunit\data\ar\elasticsearch;
use yii\elasticsearch\Command;
/**

1
tests/unit/data/ar/elasticsearch/OrderItem.php

@ -1,6 +1,7 @@
<?php
namespace yiiunit\data\ar\elasticsearch;
use yii\elasticsearch\Command;
/**

3
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;
}
}

3
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;
}
}

3
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;
}
}

3
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;
}
}

3
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;

47
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()
@ -523,6 +553,5 @@ class ActiveRecordTest extends ElasticSearchTestCase
Event::off(BaseActiveRecord::className(), BaseActiveRecord::EVENT_AFTER_FIND);
}
// TODO test AR with not mapped PK
}

1
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));
}
}

1
tests/unit/extensions/elasticsearch/QueryBuilderTest.php

@ -74,4 +74,3 @@ class QueryBuilderTest extends ElasticSearchTestCase
$this->assertEquals(3, $result['hits']['total']);
}
}

1
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;
}
}

1
tests/unit/extensions/imagine/ImageGmagickTest.php

@ -26,5 +26,4 @@ class ImageGmagickTest extends AbstractImageTest
{
return true;
}
}

1
tests/unit/extensions/imagine/ImageImagickTest.php

@ -26,5 +26,4 @@ class ImageImagickTest extends AbstractImageTest
{
return true;
}
}

48
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 getCustomerClass() { return Customer::className(); }
public function getItemClass() { return Item::className(); }
public function getOrderClass() { return Order::className(); }
public function getOrderItemClass() { return OrderItem::className(); }
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 setUp()

1
tests/unit/extensions/redis/RedisCacheTest.php

@ -97,5 +97,4 @@ class RedisCacheTest extends CacheTestCase
$cache->set($key, $data);
$this->assertTrue($cache->get($key) === $data);
}
}

1
tests/unit/framework/base/BehaviorTest.php

@ -102,5 +102,4 @@ class BehaviorTest extends TestCase
$bar->attachBehavior('bar', $behavior);
$bar->nomagicBehaviorMethod();
}
}

1
tests/unit/framework/base/EventTest.php

@ -89,5 +89,4 @@ class Post extends ActiveRecord
class User extends ActiveRecord
{
}

48
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 getCustomerClass() { return Customer::className(); }
public function getItemClass() { return Item::className(); }
public function getOrderClass() { return Order::className(); }
public function getOrderItemClass() { return OrderItem::className(); }
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 testCustomColumns()
{

1
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);
}*/
}

1
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'],
];
}
}

21
tests/unit/framework/db/mssql/MssqlQueryBuilderTest.php

@ -13,14 +13,13 @@ class MSSQLQueryBuilderTest extends QueryBuilderTest
{
public $driverName = 'sqlsrv';
public function testOffsetLimit() {
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);
$query->select('id')->from('example')->limit(10)->offset(5);
list($actualQuerySql, $actualQueryParams) = $this->getQueryBuilder()->build($query);
@ -28,14 +27,13 @@ class MSSQLQueryBuilderTest extends QueryBuilderTest
$this->assertEquals($expectedQueryParams, $actualQueryParams);
}
public function testLimit() {
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);
$query->select('id')->from('example')->limit(10);
list($actualQuerySql, $actualQueryParams) = $this->getQueryBuilder()->build($query);
@ -43,14 +41,13 @@ class MSSQLQueryBuilderTest extends QueryBuilderTest
$this->assertEquals($expectedQueryParams, $actualQueryParams);
}
public function testOffset() {
public function testOffset()
{
$expectedQuerySql = 'SELECT `id` FROM `exapmle` OFFSET 10 ROWS';
$expectedQueryParams = null;
$query = new Query();
$query->select('id')
->from('example')
->offset(10);
$query->select('id')->from('example')->offset(10);
list($actualQuerySql, $actualQueryParams) = $this->getQueryBuilder()->build($query);

20
tests/unit/framework/helpers/FileHelperTest.php

@ -255,7 +255,9 @@ 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;
@ -264,7 +266,9 @@ class FileHelperTest extends TestCase
foreach ($files as $fileName => $contents) {
$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,19 +284,25 @@ 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

1
tests/unit/framework/i18n/I18NTest.php

@ -124,4 +124,3 @@ class I18NTest extends TestCase
Event::off(PhpMessageSource::className(), PhpMessageSource::EVENT_MISSING_TRANSLATION);
}
}

1
tests/unit/framework/mail/BaseMailerTest.php

@ -240,7 +240,6 @@ class BaseMailerTest extends TestCase
$mailerMock->expects($this->once())->method('afterSend')->with($message, true);
$mailerMock->send($message);
}
}
/**

41
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 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;
}

2
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()

1
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()

2
tests/unit/framework/validators/DefaultValueValidatorTest.php

@ -1,5 +1,7 @@
<?php
namespace yiiunit\framework\validators;
use yii\validators\DefaultValueValidator;
use yiiunit\TestCase;

1
tests/unit/framework/validators/RegularExpressionValidatorTest.php

@ -50,5 +50,4 @@ class RegularExpressionValidatorTest extends TestCase
$val = new RegularExpressionValidator();
$val->validate('abc');
}
}

2
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;

1
tests/unit/framework/web/AssetConverterTest.php

@ -4,6 +4,7 @@
*/
namespace yiiunit\framework\web;
use yii\web\AssetConverter;
/**

Loading…
Cancel
Save