Skip to content

Commit

Permalink
test are fixed
Browse files Browse the repository at this point in the history
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
  • Loading branch information
julien-nc committed Sep 20, 2024
1 parent b10a652 commit abad897
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 50 deletions.
52 changes: 10 additions & 42 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ jobs:
strategy:
fail-fast: false
matrix:
#php-versions: ['8.1', '8.2', '8.3']
#server-versions: ['master']
#databases: ['sqlite', 'mysql', 'pgsql']
php-versions: ['8.3']
databases: ['sqlite']
php-versions: ['8.1', '8.2', '8.3']
server-versions: ['master']
databases: ['sqlite', 'mysql', 'pgsql']
#php-versions: ['8.3']
#databases: ['sqlite']
#server-versions: ['master']

name: php${{ matrix.php-versions }}-${{ matrix.databases }}-${{ matrix.server-versions }}

Expand Down Expand Up @@ -65,8 +65,8 @@ jobs:
php-version: ${{ matrix.php-versions }}
extensions: mbstring, intl, sqlite3, curl, xml, json, zip, gd
ini-values: post_max_size=256M, max_execution_time=180
coverage: xdebug
tools: php-cs-fixer
#coverage: xdebug
#tools: php-cs-fixer

- uses: actions/checkout@v2

Expand Down Expand Up @@ -94,41 +94,9 @@ jobs:
cd ~/html/nextcloud/apps/${{ env.APP_ID }}
composer i
- name: Perform PhpUnit tests with coverage
if: ${{ matrix.databases == 'sqlite' && matrix.php-versions == '8.3' && matrix.server-versions == 'master' }}
run: |
mkdir /tmp/coverage
cd /tmp
echo "##### PHPunit"
XDEBUG_MODE=coverage ~/html/nextcloud/apps/${{ env.APP_ID }}/vendor/bin/phpunit --configuration ~/html/nextcloud/apps/${{ env.APP_ID }}/tests/phpunit.xml --coverage-text --color=never --coverage-html coverage > /tmp/cov.txt && SUCCESS=yes || SUCCESS=no
echo "phpunit finished ############################"
cat /tmp/cov.txt
if [ $SUCCESS = "yes" ]; then echo "TESTS PASSED"; else echo "TESTS FAILED"; exit 1; fi
echo "generating badge ############################"
grep "^\s\+Lines:" /tmp/cov.txt > /tmp/cov.line.txt
grep -o "[0-9]\+\.[0-9]\+" /tmp/cov.line.txt > /tmp/cov.value.txt
mv /tmp/cov.value.txt /tmp/coverage/cov.value.txt
echo "anybadge ############################"
sudo -H pip3 install anybadge
cat /tmp/coverage/cov.value.txt
anybadge -l coverage -v `cat /tmp/coverage/cov.value.txt` -m "%.2f%%" -f /tmp/coverage/coverage.svg 50=red 70=orange 80=yellow 90=green
- name: Perform PhpUnit tests
if: ${{ !(matrix.databases == 'sqlite' && matrix.php-versions == '8.3' && matrix.server-versions == 'master') }}
#if: ${{ !(matrix.databases == 'sqlite' && matrix.php-versions == '8.3' && matrix.server-versions == 'master') }}
run: |
~/html/nextcloud/apps/${{ env.APP_ID }}/vendor/bin/phpunit --configuration ~/html/nextcloud/apps/${{ env.APP_ID }}/tests/phpunit.xml && SUCCESS=yes || SUCCESS=no
cd ~/html/nextcloud/apps/${{ env.APP_ID }}
composer run phpunit && SUCCESS=yes || SUCCESS=no
if [ $SUCCESS = "yes" ]; then echo "TESTS PASSED"; else echo "TESTS FAILED"; exit 1; fi
#- name: Upload coverage
# if: ${{ github.ref == 'refs/heads/master' && matrix.databases == 'sqlite' && matrix.php-versions == '8.0' && matrix.server-versions == 'master' }}
# uses: actions/upload-artifact@v2
# with:
# name: coverage
# path: /tmp/coverage

#- name: Deploy
# if: ${{ github.ref == 'refs/heads/master' && matrix.databases == 'sqlite' && matrix.php-versions == '8.0' && matrix.server-versions == 'master' }}
# uses: peaceiris/actions-gh-pages@v3
# with:
# github_token: ${{ secrets.GITHUB_TOKEN }}
# publish_dir: /tmp/coverage
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"psalm": "psalm.phar --no-cache",
"psalm:update-baseline": "psalm.phar --threads=1 --update-baseline",
"psalm:update-baseline:force": "psalm.phar --threads=1 --update-baseline --set-baseline=tests/psalm-baseline.xml",
"test:unit": "phpunit --config tests/phpunit.xml",
"phpunit": "phpunit --config tests/phpunit.xml",
"openapi": "generate-spec --verbose --allow-missing-docs"
},
"repositories": [
Expand Down
14 changes: 7 additions & 7 deletions tests/php/service/LocalProjectServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public static function tearDownAfterClass(): void {
$groupManager->get('group2test')->delete();
}

protected function tearDown(): void {
protected function tearDown(): void {
$this->deleteTestProjects();
}

Expand All @@ -139,6 +139,7 @@ private function deleteTestProjects(): void {
'original',
'newproject',
'superprojS',
'tsl',
];
foreach ($projIds as $projId) {
try {
Expand Down Expand Up @@ -795,7 +796,7 @@ public function testPage() {
} catch (CospendBasicException) {
}
try {
$res = $this->localProjectService->editCurrency('superproj', -1, 'dolrenamed', 2);
$res = $this->localProjectService->editCurrency('superproj', -1, 'dolrenamed', 2);
$this->assertFalse(true);
} catch (CospendBasicException) {
}
Expand Down Expand Up @@ -1540,7 +1541,6 @@ public function testPage() {

public function testSearchBills() {
$resp = $this->apiController->createProject('superprojS', 'SuperProj');
echo 'CRPRO '.json_encode($resp->getData());
$status = $resp->getStatus();
$this->assertEquals(Http::STATUS_OK, $status);
$data = $resp->getData();
Expand Down Expand Up @@ -1666,9 +1666,9 @@ public function testgetNbBills() {
}

public function createAndPopulateProject($projectId): ?array {
$resp = $this->apiController->createProject($projectId, 'SuperProj', 'toto');
$resp = $this->apiController->createProject($projectId, 'SuperProj');
$status = $resp->getStatus();
$this->assertEquals(Http::STATUS_OK, $status);
$this->assertEquals(Http::STATUS_OK, $status, $projectId . ' :: ' . json_encode($resp->getData()));
$data = $resp->getData();
$this->assertEquals($projectId, $data['id']);
$resp = $this->apiController->createMember($projectId, 'member1');
Expand Down Expand Up @@ -1799,9 +1799,9 @@ public function testShareLink() {
$this->createAndPopulateProject($projectId);

$result = $this->localProjectService->createPublicShare($projectId);
$this->assertTrue(isset($result['token']));
$this->assertTrue(isset($result['userid']));
$this->assertTrue(isset($result['id']));
$token = $result['token'];
$token = $result['userid'];

$projInfo = $this->localProjectService->getLinkShareInfoFromShareToken($token);
$this->assertEquals($projectId, $projInfo['projectid']);
Expand Down

0 comments on commit abad897

Please sign in to comment.