Commit da000165 by Klimov Paul

Method 'oneWithUpdate' renamed to 'oneWithModify' at `yii\mongodb\Query`

parent b819a678
......@@ -169,9 +169,9 @@ class ActiveQuery extends Query implements ActiveQueryInterface
* Depending on the setting of [[asArray]], the query result may be either an array or an ActiveRecord object.
* Null will be returned if the query results in nothing.
*/
public function oneWithUpdate($update, $options = [], $db = null)
public function oneWithModify($update, $options = [], $db = null)
{
$row = parent::oneWithUpdate($update, $options, $db);
$row = parent::oneWithModify($update, $options, $db);
if ($row !== null) {
$models = $this->populate([$row]);
return reset($models) ?: null;
......
......@@ -205,7 +205,7 @@ class Query extends Component implements QueryInterface
* @param Connection $db the Mongo connection used to execute the query.
* @return array|null the original document, or the modified document when $options['new'] is set.
*/
public function oneWithUpdate($update, $options = [], $db = null)
public function oneWithModify($update, $options = [], $db = null)
{
$collection = $this->getCollection($db);
if (!empty($this->orderBy)) {
......
......@@ -264,14 +264,14 @@ class ActiveRecordTest extends MongoDbTestCase
$this->assertEquals(7, $rowRefreshed->status);
}
public function testFindOneWithUpdate()
public function testFindOneWithModify()
{
$searchName = 'name7';
$newName = 'new name';
$customer = Customer::find()
->where(['name' => $searchName])
->oneWithUpdate(['$set' => ['name' => $newName]], ['new' => true]);
->oneWithModify(['$set' => ['name' => $newName]], ['new' => true]);
$this->assertTrue($customer instanceof Customer);
$this->assertEquals($newName, $customer->name);
}
......
......@@ -211,7 +211,7 @@ class QueryRunTest extends MongoDbTestCase
$this->assertEquals($rows, $rowsUppercase);
}
public function testOneWithUpdate()
public function testOneWithModify()
{
$connection = $this->getConnection();
......@@ -221,14 +221,14 @@ class QueryRunTest extends MongoDbTestCase
$newName = 'new name';
$row = $query->from('customer')
->where(['name' => $searchName])
->oneWithUpdate(['$set' => ['name' => $newName]], ['new' => false], $connection);
->oneWithModify(['$set' => ['name' => $newName]], ['new' => false], $connection);
$this->assertEquals($searchName, $row['name']);
$searchName = 'name7';
$newName = 'new name';
$row = $query->from('customer')
->where(['name' => $searchName])
->oneWithUpdate(['$set' => ['name' => $newName]], ['new' => true], $connection);
->oneWithModify(['$set' => ['name' => $newName]], ['new' => true], $connection);
$this->assertEquals($newName, $row['name']);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment