test fixes

This commit is contained in:
Dennis Eichhorn 2023-09-24 22:44:33 +00:00
parent cd0ff0c478
commit dc436833f5
2 changed files with 61 additions and 11 deletions

View File

@ -121,6 +121,28 @@ jobs:
uses: actions/checkout@main uses: actions/checkout@main
with: with:
fetch-depth: 1 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 - name: Checkout Karaka Repository
uses: actions/checkout@main uses: actions/checkout@main
with: with:
@ -128,7 +150,6 @@ jobs:
ref: develop ref: develop
repository: Karaka-Management/Karaka repository: Karaka-Management/Karaka
path: Karaka path: Karaka
submodules: recursive
- name: Setup PHP, with composer and extensions - name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@master uses: shivammathur/setup-php@master
with: with:
@ -197,7 +218,7 @@ jobs:
- name: Setup Composer - name: Setup Composer
run: composer install run: composer install
- name: phpstan - 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: codestyle-tests:
runs-on: ubuntu-latest runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, 'NO_CI')" 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 run: vendor/bin/phpcs --severity=1 ./ --standard="Build/Config/phpcs.xml" -s --report=full
- name: rector - name: rector
run: vendor/bin/rector process --dry-run --config Build/Config/rector.php ./ run: vendor/bin/rector process --dry-run --config Build/Config/rector.php ./
# - name: Install NPM - name: Install NPM
# uses: actions/setup-node@v3 uses: actions/setup-node@v3
# with: with:
# node-version: '14' node-version: '14'
# cache: 'npm' cache: 'npm'
# - run: npm install - run: npm install
# - name: eslint - name: eslint
# run: npx eslint ./ -c Build/Config/.eslintrc.json run: npx eslint ./ -c Build/Config/.eslintrc.json
# linting: # linting:
# runs-on: ubuntu-latest # runs-on: ubuntu-latest
# if: "!contains(github.event.head_commit.message, 'NO_CI')" # if: "!contains(github.event.head_commit.message, 'NO_CI')"

View File

@ -14,6 +14,11 @@ declare(strict_types=1);
namespace Modules\Tasks\tests\Views; 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; use Modules\Tasks\Views\TaskView;
/** /**
@ -38,8 +43,32 @@ class TaskViewTest extends \PHPUnit\Framework\TestCase
*/ */
public function testAccountImageUrl() : void 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)); self::assertEquals('Web/Backend/img/default-user.jpg', $view->getAccountImage(1));
} }
} }