Skip to content

Commit

Permalink
fix: Skip tests if analytics app is not installed
Browse files Browse the repository at this point in the history
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
  • Loading branch information
susnux committed Jun 12, 2024
1 parent 56341de commit 2f4feae
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/phpunit-mariadb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ jobs:
with:
path: apps/${{ env.APP_NAME }}

- name: Checkout circles dependency
- name: Checkout teams dependency
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
repository: nextcloud/circles
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/phpunit-mysql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ jobs:
with:
path: apps/${{ env.APP_NAME }}

- name: Checkout circles dependency
- name: Checkout teams dependency
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
repository: nextcloud/circles
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/phpunit-oci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ jobs:
with:
path: apps/${{ env.APP_NAME }}

- name: Checkout circles dependency
- name: Checkout teams dependency
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
repository: nextcloud/circles
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/phpunit-pgsql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ jobs:
with:
path: apps/${{ env.APP_NAME }}

- name: Checkout circles dependency
- name: Checkout teams dependency
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
repository: nextcloud/circles
Expand Down
9 changes: 8 additions & 1 deletion .github/workflows/phpunit-sqlite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,20 @@ jobs:
with:
path: apps/${{ env.APP_NAME }}

- name: Checkout circles dependency
- name: Checkout teams app
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
repository: nextcloud/circles
ref: ${{ matrix.server-versions }}
path: apps/circles

- name: Checkout analytics app
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
repository: rello/analytics
ref: ${{ matrix.server-versions }}
path: apps/analytics

- name: Set up php ${{ matrix.php-versions }}
uses: shivammathur/setup-php@fc14643b0a99ee9db10a3c025a33d76544fa3761 # v2
with:
Expand Down
17 changes: 12 additions & 5 deletions tests/Unit/Analytics/AnalyticsDatasourceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
*/
namespace OCA\Forms\Tests\Unit\Analytics;

use OCA\Analytics\Datasource\IDatasource;
use OCA\Forms\Analytics\AnalyticsDatasource;
use OCA\Forms\Db\FormMapper;
use OCA\Forms\Service\FormsService;
Expand All @@ -35,8 +36,6 @@

class AnalyticsDatasourceTest extends TestCase {

private AnalyticsDatasource $dataSource;

private IL10N|MockObject $l10n;
private LoggerInterface|MockObject $logger;
private FormMapper|MockObject $formMapper;
Expand All @@ -45,13 +44,21 @@ class AnalyticsDatasourceTest extends TestCase {

public function setUp(): void {
parent::setUp();

if (!\class_exists(IDatasource::class)) {
$this->markTestSkipped('The analytics app is not installed!');
return;
}

$this->l10n = $this->createMock(IL10N::class);
$this->logger = $this->createMock(LoggerInterface::class);
$this->formMapper = $this->createMock(FormMapper::class);
$this->formsService = $this->createMock(FormsService::class);
$this->submissionService = $this->createMock(SubmissionService::class);
}

$this->dataSource = new AnalyticsDatasource(
protected function mockDatasource() {
return new AnalyticsDatasource(
null,
$this->l10n,
$this->logger,
Expand All @@ -66,11 +73,11 @@ public function testGetName() {
->expects($this->any())
->method('t')
->willReturnCallback(fn (string $str) => $str);
$this->assertEquals('Nextcloud Forms', $this->dataSource->getName());
$this->assertEquals('Nextcloud Forms', $this->mockDatasource()->getName());
}

public function testGetId() {
$this->assertEquals(66, $this->dataSource->getId());
$this->assertEquals(66, $this->mockDatasource()->getId());
}

// TODO: Write tests for `getTemplate` and `readData`
Expand Down

0 comments on commit 2f4feae

Please sign in to comment.