From dc436833f5050d349389ef5dbfc7660470d028e5 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sun, 24 Sep 2023 22:44:33 +0000 Subject: [PATCH] test fixes --- .github/workflows/main.yml | 41 +++++++++++++++++++++++++++--------- tests/Views/TaskViewTest.php | 31 ++++++++++++++++++++++++++- 2 files changed, 61 insertions(+), 11 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5bfa109..7618968 100755 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -121,6 +121,28 @@ jobs: uses: actions/checkout@main with: fetch-depth: 1 + - name: Checkout Build Repository + uses: actions/checkout@main + with: + fetch-depth: 1 + ref: develop + repository: Karaka-Management/Build + path: Build + - name: Checkout Resource Repository + uses: actions/checkout@main + with: + fetch-depth: 1 + ref: develop + repository: Karaka-Management/Resources + path: Resources + - name: Checkout phpOMS Repository + uses: actions/checkout@main + with: + fetch-depth: 1 + ref: develop + repository: Karaka-Management/phpOMS + path: phpOMS + token: ${{ secrets.GH_PAT }} - name: Checkout Karaka Repository uses: actions/checkout@main with: @@ -128,7 +150,6 @@ jobs: ref: develop repository: Karaka-Management/Karaka path: Karaka - submodules: recursive - name: Setup PHP, with composer and extensions uses: shivammathur/setup-php@master with: @@ -197,7 +218,7 @@ jobs: - name: Setup Composer run: composer install - name: phpstan - run: vendor/bin/phpstan analyse -a tests/Autoloader.php --no-progress -l 9 -c Build/Config/phpstan.neon ./ + run: vendor/bin/phpstan analyse -a phpOMS/Autoloader.php --no-progress -l 9 -c Build/Config/phpstan.neon ./ codestyle-tests: runs-on: ubuntu-latest if: "!contains(github.event.head_commit.message, 'NO_CI')" @@ -241,14 +262,14 @@ jobs: run: vendor/bin/phpcs --severity=1 ./ --standard="Build/Config/phpcs.xml" -s --report=full - name: rector run: vendor/bin/rector process --dry-run --config Build/Config/rector.php ./ - # - name: Install NPM - # uses: actions/setup-node@v3 - # with: - # node-version: '14' - # cache: 'npm' - # - run: npm install - # - name: eslint - # run: npx eslint ./ -c Build/Config/.eslintrc.json + - name: Install NPM + uses: actions/setup-node@v3 + with: + node-version: '14' + cache: 'npm' + - run: npm install + - name: eslint + run: npx eslint ./ -c Build/Config/.eslintrc.json # linting: # runs-on: ubuntu-latest # if: "!contains(github.event.head_commit.message, 'NO_CI')" diff --git a/tests/Views/TaskViewTest.php b/tests/Views/TaskViewTest.php index fe1462b..2056d9a 100755 --- a/tests/Views/TaskViewTest.php +++ b/tests/Views/TaskViewTest.php @@ -14,6 +14,11 @@ declare(strict_types=1); namespace Modules\Tasks\tests\Views; +use Modules\Admin\Models\AccountMapper; +use Modules\Admin\Models\NullAccount; +use Modules\Media\Models\Media; +use Modules\Profile\Models\Profile; +use Modules\Profile\Models\ProfileMapper; use Modules\Tasks\Views\TaskView; /** @@ -38,8 +43,32 @@ class TaskViewTest extends \PHPUnit\Framework\TestCase */ public function testAccountImageUrl() : void { - $view = new TaskView(); + $media = new Media(); + $media->createdBy = new NullAccount(1); + $media->description = 'desc'; + $media->setPath('Web/Backend/img/default-user.jpg'); + $media->size = 11; + $media->extension = 'png'; + $media->name = 'Image'; + if (($profile = ProfileMapper::get()->where('account', 1)->execute())->id === 0) { + $profile = new Profile(); + + $profile->account = AccountMapper::get()->where('id', 1)->execute(); + $profile->image = $media; + $profile->birthday = new \DateTime('now'); + + $id = ProfileMapper::create()->execute($profile); + self::assertGreaterThan(0, $profile->id); + self::assertEquals($id, $profile->id); + } else { + $profile->image = $media; + $profile->birthday = new \DateTime('now'); + + ProfileMapper::update()->with('image')->execute($profile); + } + + $view = new TaskView(); self::assertEquals('Web/Backend/img/default-user.jpg', $view->getAccountImage(1)); } }