/** * @covers Alchemy\Phrasea\Controller\Prod\Upload::upload * @covers Alchemy\Phrasea\Controller\Prod\Upload::getJsonResponse */ public function testUpload() { self::$DI['app']['notification.deliverer'] = $this->getMockBuilder('Alchemy\\Phrasea\\Notification\\Deliverer')->disableOriginalConstructor()->getMock(); $data = DataURI\Data::buildFromFile(__DIR__ . '/../../../../../files/cestlafete.jpg'); $params = ['base_id' => self::$DI['collection']->get_base_id(), 'b64_image' => DataURI\Dumper::dump($data)]; $files = ['files' => [new UploadedFile($this->tmpFile, 'KIKOO.JPG')]]; self::$DI['client']->request('POST', '/prod/upload/', $params, $files, ['HTTP_Accept' => 'application/json']); $response = self::$DI['client']->getResponse(); $this->checkJsonResponse($response); $datas = json_decode($response->getContent(), true); $this->assertTrue($datas['success']); if ($datas['element'] == 'record') { $id = explode('_', $datas['id']); $record = new \record_adapter(self::$DI['app'], $id[0], $id[1]); $this->assertTrue($record->get_thumbnail()->is_physically_present()); } }
/** * @covers Alchemy\Phrasea\Controller\Prod\Upload::upload * @covers Alchemy\Phrasea\Controller\Prod\Upload::getJsonResponse */ public function testUpload() { self::$DI['app']['notification.deliverer'] = $this->getMockBuilder('Alchemy\\Phrasea\\Notification\\Deliverer')->disableOriginalConstructor()->getMock(); $data = DataURI\Data::buildFromFile(__DIR__ . '/../../../../../files/cestlafete.jpg'); $params = ['base_id' => self::$DI['collection']->get_base_id(), 'b64_image' => DataURI\Dumper::dump($data)]; $files = ['files' => [new UploadedFile($this->tmpFile, 'KIKOO.JPG')]]; /** @var Client $client */ $client = self::$DI['client']; $client->request('POST', '/prod/upload/', $params, $files, ['HTTP_Accept' => 'application/json']); $response = $client->getResponse(); $this->checkJsonResponse($response); $datas = json_decode($response->getContent(), true); $this->assertTrue($datas['success']); $this->assertArrayHasKey('element', $datas); // Below is useless test as currently a lazaret intance is returned if ('record' == $datas['element']) { $id = explode('_', $datas['id']); $record = new \record_adapter(self::$DI['app'], $id[0], $id[1]); $this->assertTrue($record->get_thumbnail()->is_physically_present()); $fields = $record->get_caption()->get_fields(['FileName']); $field = array_pop($fields); $this->assertEquals('KIKOO.JPG', $field->get_serialized_values()); } }