public function testGetMailContent() { $en = new Mail($this->container); $p = new Project($this->container); $tf = new TaskFinder($this->container); $tc = new TaskCreation($this->container); $s = new Subtask($this->container); $c = new Comment($this->container); $f = new File($this->container); $this->assertEquals(1, $p->create(array('name' => 'test'))); $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1))); $this->assertEquals(1, $s->create(array('title' => 'test', 'task_id' => 1))); $this->assertEquals(1, $c->create(array('comment' => 'test', 'task_id' => 1, 'user_id' => 1))); $this->assertEquals(1, $f->create(1, 'test', 'blah', 123)); $task = $tf->getDetails(1); $subtask = $s->getById(1, true); $comment = $c->getById(1); $file = $c->getById(1); $this->assertNotEmpty($task); $this->assertNotEmpty($subtask); $this->assertNotEmpty($comment); $this->assertNotEmpty($file); foreach (NotificationSubscriber::getSubscribedEvents() as $event => $values) { $this->assertNotEmpty($en->getMailContent($event, array('task' => $task, 'comment' => $comment, 'subtask' => $subtask, 'file' => $file, 'changes' => array()))); $this->assertNotEmpty($en->getMailSubject($event, array('task' => $task, 'comment' => $comment, 'subtask' => $subtask, 'file' => $file, 'changes' => array()))); } }
public function testGetTitle() { $wn = new Notification($this->container); $p = new Project($this->container); $tf = new TaskFinder($this->container); $tc = new TaskCreation($this->container); $s = new Subtask($this->container); $c = new Comment($this->container); $f = new File($this->container); $this->assertEquals(1, $p->create(array('name' => 'test'))); $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1))); $this->assertEquals(1, $s->create(array('title' => 'test', 'task_id' => 1))); $this->assertEquals(1, $c->create(array('comment' => 'test', 'task_id' => 1, 'user_id' => 1))); $this->assertEquals(1, $f->create(1, 'test', 'blah', 123)); $task = $tf->getDetails(1); $subtask = $s->getById(1, true); $comment = $c->getById(1); $file = $c->getById(1); $this->assertNotEmpty($task); $this->assertNotEmpty($subtask); $this->assertNotEmpty($comment); $this->assertNotEmpty($file); foreach (NotificationSubscriber::getSubscribedEvents() as $event_name => $values) { $title = $wn->getTitleWithoutAuthor($event_name, array('task' => $task, 'comment' => $comment, 'subtask' => $subtask, 'file' => $file, 'changes' => array())); $this->assertNotEmpty($title); $title = $wn->getTitleWithAuthor('foobar', $event_name, array('task' => $task, 'comment' => $comment, 'subtask' => $subtask, 'file' => $file, 'changes' => array())); $this->assertNotEmpty($title); } $this->assertNotEmpty($wn->getTitleWithoutAuthor(Task::EVENT_OVERDUE, array('tasks' => array(array('id' => 1))))); $this->assertNotEmpty($wn->getTitleWithoutAuthor('unkown', array())); }
public function testRemove() { $p = new Project($this->container); $f = new File($this->container); $tc = new TaskCreation($this->container); $this->assertEquals(1, $p->create(array('name' => 'test'))); $this->assertEquals(1, $tc->create(array('project_id' => 1, 'title' => 'test'))); $this->assertEquals(1, $f->create(1, 'B.pdf', '/tmp/foo1', 10)); $this->assertEquals(2, $f->create(1, 'A.png', '/tmp/foo2', 10)); $this->assertEquals(3, $f->create(1, 'D.doc', '/tmp/foo3', 10)); $this->container['objectStorage']->expects($this->at(0))->method('remove')->with($this->equalTo('/tmp/foo2'))->will($this->returnValue(true)); $this->container['objectStorage']->expects($this->at(1))->method('remove')->with($this->equalTo('thumbnails//tmp/foo2'))->will($this->returnValue(true)); $this->container['objectStorage']->expects($this->at(2))->method('remove')->with($this->equalTo('/tmp/foo1'))->will($this->returnValue(true)); $this->container['objectStorage']->expects($this->at(3))->method('remove')->with($this->equalTo('/tmp/foo3'))->will($this->returnValue(true)); $this->assertTrue($f->remove(2)); $files = $f->getAll(1); $this->assertNotEmpty($files); $this->assertCount(2, $files); $this->assertEquals('B.pdf', $files[0]['name']); $this->assertEquals('D.doc', $files[1]['name']); $this->assertTrue($f->removeAll(1)); $files = $f->getAll(1); $this->assertEmpty($files); }