Skip to content

Commit

Permalink
pipeline fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Konstantin Myakshin <molodchick@gmail.com>
  • Loading branch information
Koc committed Dec 29, 2023
1 parent 9c5f5ae commit 6775c89
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 11 deletions.
2 changes: 1 addition & 1 deletion appinfo/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@
// Submissions linking with file in cloud
[
'name' => 'api#linkFile',
'url' => '/api/{apiVersion}/link/link/{fileFormat}',
'url' => '/api/{apiVersion}/form/link/{fileFormat}',
'verb' => 'POST',
'requirements' => [
'apiVersion' => 'v2(\.3)?',
Expand Down
5 changes: 3 additions & 2 deletions lib/Service/SubmissionService.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
use OCA\Forms\Db\QuestionMapper;
use OCA\Forms\Db\SubmissionMapper;
use OCP\AppFramework\Db\DoesNotExistException;
use OCP\AppFramework\OCS\OCSException;;
use OCP\AppFramework\OCS\OCSException;
use OCP\Files\File;
use OCP\Files\IRootFolder;
use OCP\Files\NotPermittedException;
Expand All @@ -48,12 +48,13 @@
use OCP\IUserManager;
use OCP\IUserSession;
use OCP\Mail\IMailer;
use Psr\Log\LoggerInterface;

use PhpOffice\PhpSpreadsheet\IOFactory;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Csv;

use Psr\Log\LoggerInterface;

class SubmissionService {
/** @var FormMapper */
private $formMapper;
Expand Down
6 changes: 3 additions & 3 deletions tests/Integration/Api/ApiV2Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -1285,7 +1285,7 @@ public function testExportSubmissions(string $expected) {
}

public function testLinkedFile() {
$resp = $this->http->request('GET', "api/v2.2/submissions/linkedFile/{$this->testForms[0]['hash']}");
$resp = $this->http->request('GET', "api/v2.3/form/linkedFile/{$this->testForms[0]['hash']}");

$this->assertEquals(200, $resp->getStatusCode());
$data = $this->OcsResponse2Data($resp);
Expand All @@ -1294,7 +1294,7 @@ public function testLinkedFile() {
}

public function testLinkFile() {
$resp = $this->http->request('POST', 'api/v2.2/submissions/link/csv', [
$resp = $this->http->request('POST', 'api/v2.3/form/link/csv', [
'json' => [
'hash' => $this->testForms[0]['hash'],
'path' => ''
Expand All @@ -1307,7 +1307,7 @@ public function testLinkFile() {
}

public function testUnlinkFile() {
$resp = $this->http->request('POST', 'api/v2.2/submissions/unlink', [
$resp = $this->http->request('POST', 'api/v2.3/form/unlink', [
'json' => [
'hash' => $this->testForms[1]['hash'],
'path' => ''
Expand Down
6 changes: 3 additions & 3 deletions tests/Unit/Controller/ApiControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ public function testExportSubmissions() {
->willReturn($csv);

$fileName = 'foo.csv';
$this->submissionService->expects($this->once())
$this->formsService->expects($this->once())
->method('getFileName')
->with($form, 'csv')
->willReturn($fileName);
Expand Down Expand Up @@ -362,7 +362,7 @@ public function testGetLinkedFile() {
->with('hash')
->willReturn($form);

$this->submissionService->expects($this->once())
$this->formsService->expects($this->once())
->method('getFilePath')
->with($form)
->willReturn('foo/bar');
Expand Down Expand Up @@ -744,7 +744,7 @@ public function testInsertSubmission_answers() {
->method('notifyNewSubmission')
->with($form, 'currentUser');

$this->submissionService->expects($this->once())
$this->formsService->expects($this->once())
->method('getFilePath')
->willReturn('foo/bar');

Expand Down
15 changes: 14 additions & 1 deletion tests/Unit/Service/FormsServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@
use OCA\Forms\Service\CirclesService;
use OCA\Forms\Service\ConfigService;
use OCA\Forms\Service\FormsService;
use OCP\Files\IRootFolder;
use OCP\IGroup;
use OCP\IGroupManager;
use OCP\IL10N;
use OCP\IUser;
use OCP\IUserManager;
use OCP\IUserSession;
Expand Down Expand Up @@ -118,6 +120,15 @@ public function setUp(): void {
->method('getUser')
->willReturn($user);

$this->storage = $this->createMock(IRootFolder::class);

$this->l10n = $this->createMock(IL10N::class);
$this->l10n->expects($this->any())
->method('t')
->will($this->returnCallback(function (string $identity) {
return $identity;
}));

$this->formsService = new FormsService(
$userSession,
$this->activityManager,
Expand All @@ -131,7 +142,9 @@ public function setUp(): void {
$this->logger,
$this->userManager,
$this->secureRandom,
$this->circlesService
$this->circlesService,
$this->storage,
$this->l10n
);
}

Expand Down
9 changes: 8 additions & 1 deletion tests/Unit/Service/SubmissionServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
use OCA\Forms\Db\QuestionMapper;
use OCA\Forms\Db\Submission;
use OCA\Forms\Db\SubmissionMapper;
use OCA\Forms\Service\FormsService;
use OCA\Forms\Service\SubmissionService;

use OCP\Files\File;
Expand Down Expand Up @@ -89,6 +90,9 @@ class SubmissionServiceTest extends TestCase {
/** @var ITempManager|MockObject */
private $tempManager;

/** @var FormsService|MockObject */
private $formsService;

public function setUp(): void {
parent::setUp();
$this->formMapper = $this->createMock(FormMapper::class);
Expand Down Expand Up @@ -118,6 +122,8 @@ public function setUp(): void {
return $identity;
}));

$this->formsService = $this->createMock(FormsService::class);

$this->submissionService = new SubmissionService(
$this->formMapper,
$this->questionMapper,
Expand All @@ -130,7 +136,8 @@ public function setUp(): void {
$this->userManager,
$userSession,
$this->mailer,
$this->tempManager
$this->tempManager,
$this->formsService
);
}

Expand Down

0 comments on commit 6775c89

Please sign in to comment.