public function testUploadFileContent() { $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'))); $data = base64_encode('file data'); $this->container['objectStorage']->expects($this->once())->method('put')->with($this->stringContains('1/1/'), $this->equalTo(base64_decode($data)))->will($this->returnValue(true)); $this->assertEquals(1, $f->uploadContent(1, 1, 'my file.pdf', $data)); $file = $f->getById(1); $this->assertNotEmpty($file); $this->assertEquals('my file.pdf', $file['name']); $this->assertStringStartsWith('1/1/', $file['path']); $this->assertEquals(0, $file['is_image']); $this->assertEquals(1, $file['task_id']); $this->assertEquals(time(), $file['date'], '', 2); $this->assertEquals(0, $file['user_id']); $this->assertEquals(9, $file['size']); }
public function testUploadFileContent() { $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->uploadContent(1, 1, 'my file.pdf', base64_encode('file data'))); $file = $f->getById(1); $this->assertNotEmpty($file); $this->assertEquals('my file.pdf', $file['name']); $this->assertStringStartsWith('1/1/', $file['path']); $this->assertEquals(0, $file['is_image']); $this->assertEquals(1, $file['task_id']); $this->assertEquals(time(), $file['date'], '', 2); $this->assertEquals(0, $file['user_id']); $this->assertEquals(9, $file['size']); }