Пример #1
0
 public function testCreationFileNameTooLong()
 {
     $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->assertTrue($f->create(1, 'test', '/tmp/foo', false, 10));
     $this->assertTrue($f->create(1, str_repeat('a', 1000), '/tmp/foo', false, 10));
     $files = $f->getAll(1);
     $this->assertNotEmpty($files);
     $this->assertCount(2, $files);
     $this->assertEquals(str_repeat('a', 255), $files[0]['name']);
     $this->assertEquals('test', $files[1]['name']);
 }
Пример #2
0
 public function testGetTitle()
 {
     $wn = new WebNotification($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 (Subscriber\NotificationSubscriber::getSubscribedEvents() as $event_name => $values) {
         $title = $wn->getTitleFromEvent($event_name, array('task' => $task, 'comment' => $comment, 'subtask' => $subtask, 'file' => $file, 'changes' => array()));
         $this->assertNotEmpty($title);
     }
     $this->assertNotEmpty($wn->getTitleFromEvent(Task::EVENT_OVERDUE, array('tasks' => array(array('id' => 1)))));
     $this->assertNotEmpty($wn->getTitleFromEvent('unkown', array()));
 }
Пример #3
0
 public function testGetMailContent()
 {
     $en = new EmailNotification($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 (Subscriber\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())));
     }
 }
Пример #4
0
 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('/tmp/foo1'))->will($this->returnValue(true));
     $this->container['objectStorage']->expects($this->at(2))->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);
 }
Пример #5
0
 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/foo', 10));
     $this->assertEquals(2, $f->create(1, 'A.png', '/tmp/foo', 10));
     $this->assertEquals(3, $f->create(1, 'D.doc', '/tmp/foo', 10));
     $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);
 }
Пример #6
0
 function import($folder_id, $part_id)
 {
     $folder = Folder::find_by_id($folder_id);
     $part = Part::find_by_id($part_id);
     if ($folder && $part) {
         // 复制零件节点
         $file = File::create(array('folder_id' => $folder_id, 'name' => $part->name, 'graphic_num' => $part->graphic_num, 'image' => $part->image));
         // 添加零件工序节点
         foreach ($part->processes as $p) {
             $unit = Unit::create(array('file_id' => $file->id, 'priority' => $p->priority, 'name' => $p->name, 'content' => $p->content, 'price' => $p->price, 'image' => $p->image, 'takt_time' => $p->takt_time, 'preparation_time' => $p->preparation_time, 'remark' => $p->remark));
             $unit->save();
         }
         //
         $node = array('id' => $file->id, 'name' => $file->name . ' (' . count($file->units) . ')', 'type' => 'file', 'isParent' => count($file->units) ? true : false, 'icon' => get_path('/webroot/css/img/diy/3.png', true));
         echo json_encode($node);
     }
 }