From bcbb3297860a8fe106094fefc04f74af4e30aed2 Mon Sep 17 00:00:00 2001
From: Frederic Guillot <fred@kanboard.net>
Date: Sun, 17 Jan 2016 17:43:11 -0500
Subject: Make sure that no events are fired if nothing have been modified in
 the task

---
 tests/units/Model/TaskModificationTest.php | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

(limited to 'tests')

diff --git a/tests/units/Model/TaskModificationTest.php b/tests/units/Model/TaskModificationTest.php
index 25a4952e..119201f0 100644
--- a/tests/units/Model/TaskModificationTest.php
+++ b/tests/units/Model/TaskModificationTest.php
@@ -41,6 +41,24 @@ class TaskModificationTest extends Base
         $this->assertEquals(1, $event_data['owner_id']);
     }
 
+    public function testThatNoEventAreFiredWhenNoChanges()
+    {
+        $p = new Project($this->container);
+        $tc = new TaskCreation($this->container);
+        $tm = new TaskModification($this->container);
+        $tf = new TaskFinder($this->container);
+
+        $this->assertEquals(1, $p->create(array('name' => 'test')));
+        $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1)));
+
+        $this->container['dispatcher']->addListener(Task::EVENT_CREATE_UPDATE, array($this, 'onCreateUpdate'));
+        $this->container['dispatcher']->addListener(Task::EVENT_UPDATE, array($this, 'onUpdate'));
+
+        $this->assertTrue($tm->update(array('id' => 1, 'title' => 'test')));
+
+        $this->assertEmpty($this->container['dispatcher']->getCalledListeners());
+    }
+
     public function testChangeTitle()
     {
         $p = new Project($this->container);
-- 
cgit v1.2.3