Exemplo n.º 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']);
 }
Exemplo n.º 2
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);
 }
Exemplo n.º 3
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);
 }