"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "tests/framework/ar/ActiveRecordTestTrait.php" between
yii2-2.0.36.tar.gz and yii2-2.0.37.tar.gz

About: Yii 2 is a high-performance component-based PHP framework for developing large-scale Web applications (source).

ActiveRecordTestTrait.php  (yii2-2.0.36):ActiveRecordTestTrait.php  (yii2-2.0.37)
skipping to change at line 12 skipping to change at line 12
/** /**
* @link http://www.yiiframework.com/ * @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC * @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/ * @license http://www.yiiframework.com/license/
*/ */
namespace yiiunit\framework\ar; namespace yiiunit\framework\ar;
use yii\base\Event; use yii\base\Event;
use yii\db\BaseActiveRecord; use yii\db\BaseActiveRecord;
use yii\db\Expression;
use yiiunit\data\ar\Customer; use yiiunit\data\ar\Customer;
use yiiunit\data\ar\Order; use yiiunit\data\ar\Order;
use yiiunit\TestCase; use yiiunit\TestCase;
/** /**
* This trait provides unit tests shared by the different AR implementations. * This trait provides unit tests shared by the different AR implementations.
* *
* It is used directly in the unit tests for database active records in `tests/f ramework/db/ActiveRecordTest.php` * It is used directly in the unit tests for database active records in `tests/f ramework/db/ActiveRecordTest.php`
* but also used in the test suites of `redis`, `mongodb`, `elasticsearch` and ` sphinx` AR implementations * but also used in the test suites of `redis`, `mongodb`, `elasticsearch` and ` sphinx` AR implementations
* in the extensions. * in the extensions.
skipping to change at line 107 skipping to change at line 108
$customer = $customerClass::findOne(['id' => 5]); $customer = $customerClass::findOne(['id' => 5]);
$this->assertNull($customer); $this->assertNull($customer);
$customer = $customerClass::findOne(['name' => 'user5']); $customer = $customerClass::findOne(['name' => 'user5']);
$this->assertNull($customer); $this->assertNull($customer);
// find by attributes // find by attributes
$customer = $customerClass::find()->where(['name' => 'user2'])->one(); $customer = $customerClass::find()->where(['name' => 'user2'])->one();
$this->assertInstanceOf($customerClass, $customer); $this->assertInstanceOf($customerClass, $customer);
$this->assertEquals(2, $customer->id); $this->assertEquals(2, $customer->id);
// find by expression
$customer = $customerClass::findOne(new Expression('id = :id', [':id' =>
2]));
$this->assertInstanceOf($customerClass, $customer);
$this->assertEquals('user2', $customer->name);
$customer = $customerClass::findOne(new Expression('id = :id AND name =
:name', [':id' => 2, ':name' => 'user1']));
$this->assertNull($customer);
$customer = $customerClass::findOne(new Expression('id = :id', [':id' =>
5]));
$this->assertNull($customer);
$customer = $customerClass::findOne(new Expression('name = :name', [':na
me' => 'user5']));
$this->assertNull($customer);
// scope // scope
$this->assertCount(2, $customerClass::find()->active()->all()); $this->assertCount(2, $customerClass::find()->active()->all());
$this->assertEquals(2, $customerClass::find()->active()->count()); $this->assertEquals(2, $customerClass::find()->active()->count());
} }
public function testFindAsArray() public function testFindAsArray()
{ {
/* @var $customerClass \yii\db\ActiveRecordInterface */ /* @var $customerClass \yii\db\ActiveRecordInterface */
$customerClass = $this->getCustomerClass(); $customerClass = $this->getCustomerClass();
 End of changes. 2 change blocks. 
0 lines changed or deleted 16 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)