From 6fbd710d6ca1e9d3978df96d3f9899a23e4fca8a Mon Sep 17 00:00:00 2001
From: Klimov Paul <klimov.paul@gmail.com>
Date: Mon, 1 Dec 2014 15:49:47 +0200
Subject: [PATCH] Extra unit test for `yii\mongodb\Query::modify()` added

---
 tests/unit/extensions/mongodb/ActiveRecordTest.php | 5 +++++
 tests/unit/extensions/mongodb/QueryRunTest.php     | 5 +++++
 2 files changed, 10 insertions(+)

diff --git a/tests/unit/extensions/mongodb/ActiveRecordTest.php b/tests/unit/extensions/mongodb/ActiveRecordTest.php
index 177f5b1..ac0f12c 100644
--- a/tests/unit/extensions/mongodb/ActiveRecordTest.php
+++ b/tests/unit/extensions/mongodb/ActiveRecordTest.php
@@ -274,6 +274,11 @@ class ActiveRecordTest extends MongoDbTestCase
             ->modify(['$set' => ['name' => $newName]], ['new' => true]);
         $this->assertTrue($customer instanceof Customer);
         $this->assertEquals($newName, $customer->name);
+
+        $customer = Customer::find()
+            ->where(['name' => 'not existing name'])
+            ->modify(['$set' => ['name' => $newName]], ['new' => false]);
+        $this->assertNull($customer);
     }
 
     /**
diff --git a/tests/unit/extensions/mongodb/QueryRunTest.php b/tests/unit/extensions/mongodb/QueryRunTest.php
index 46dceaf..0f7665d 100644
--- a/tests/unit/extensions/mongodb/QueryRunTest.php
+++ b/tests/unit/extensions/mongodb/QueryRunTest.php
@@ -230,6 +230,11 @@ class QueryRunTest extends MongoDbTestCase
             ->where(['name' => $searchName])
             ->modify(['$set' => ['name' => $newName]], ['new' => true], $connection);
         $this->assertEquals($newName, $row['name']);
+
+        $row = $query->from('customer')
+            ->where(['name' => 'not existing name'])
+            ->modify(['$set' => ['name' => 'new name']], ['new' => false], $connection);
+        $this->assertNull($row);
     }
 
     /**
--
libgit2 0.27.1