Example #1
0
 public function testIsLastModified()
 {
     $p = new Project($this->container);
     $tc = new TaskCreation($this->container);
     $now = time();
     $this->assertEquals(1, $p->create(array('name' => 'UnitTest')));
     $project = $p->getById(1);
     $this->assertNotEmpty($project);
     $this->assertEquals($now, $project['last_modified']);
     sleep(1);
     $listener = new ProjectModificationDateSubscriber($this->container);
     $this->container['dispatcher']->addListener(Task::EVENT_CREATE_UPDATE, array($listener, 'execute'));
     $this->assertEquals(1, $tc->create(array('title' => 'Task #1', 'project_id' => 1)));
     $called = $this->container['dispatcher']->getCalledListeners();
     $this->assertArrayHasKey(Task::EVENT_CREATE_UPDATE . '.Kanboard\\Subscriber\\ProjectModificationDateSubscriber::execute', $called);
     $project = $p->getById(1);
     $this->assertNotEmpty($project);
     $this->assertTrue($p->isModifiedSince(1, $now));
 }