public function testIsLastModified() { $p = new Project($this->container); $tc = new TaskCreation($this->container); $now = time(); $p->attachEvents(); $this->assertEquals(1, $p->create(array('name' => 'UnitTest'))); $project = $p->getById(1); $this->assertNotEmpty($project); $this->assertEquals($now, $project['last_modified']); sleep(1); $this->assertEquals(1, $tc->create(array('title' => 'Task #1', 'project_id' => 1))); $this->assertTrue($this->container['event']->isEventTriggered(Task::EVENT_CREATE)); $this->assertEquals('Event\\ProjectModificationDateListener', $this->container['event']->getLastListenerExecuted()); $project = $p->getById(1); $this->assertNotEmpty($project); $this->assertTrue($p->isModifiedSince(1, $now)); }
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 . '.Subscriber\\ProjectModificationDateSubscriber::execute', $called); $project = $p->getById(1); $this->assertNotEmpty($project); $this->assertTrue($p->isModifiedSince(1, $now)); }