upgrade phpunit

This commit is contained in:
Dennis Eichhorn 2024-03-20 05:16:00 +00:00
parent 80176a5f3e
commit 3c55705373
9 changed files with 65 additions and 138 deletions

View File

@ -38,6 +38,7 @@ use phpOMS\Utils\TestUtils;
/**
* @internal
*/
#[\PHPUnit\Framework\Attributes\CoversClass(\Modules\Profile\Controller\ApiController::class)]
final class ApiControllerTest extends \PHPUnit\Framework\TestCase
{
protected ApplicationAbstract $app;
@ -91,10 +92,7 @@ final class ApiControllerTest extends \PHPUnit\Framework\TestCase
TestUtils::setMember($this->module, 'app', $this->app);
}
/**
* @covers \Modules\Profile\Controller\ApiController
* @group module
*/
#[\PHPUnit\Framework\Attributes\Group('module')]
public function testApiProfileCreate() : void
{
\Modules\Admin\tests\Helper::createAccounts(1);
@ -110,10 +108,7 @@ final class ApiControllerTest extends \PHPUnit\Framework\TestCase
self::assertGreaterThan(0, $response->getDataArray('')['response'][0]->id);
}
/**
* @covers \Modules\Profile\Controller\ApiController
* @group module
*/
#[\PHPUnit\Framework\Attributes\Group('module')]
public function testApiProfileTempLoginCreate() : void
{
$response = new HttpResponse();
@ -125,10 +120,7 @@ final class ApiControllerTest extends \PHPUnit\Framework\TestCase
self::assertGreaterThan(31, \strlen($response->getDataArray('')['response']));
}
/**
* @covers \Modules\Profile\Controller\ApiController
* @group module
*/
#[\PHPUnit\Framework\Attributes\Group('module')]
public function testApiProfileImageSet() : void
{
\copy(__DIR__ . '/icon.png', __DIR__ . '/temp_icon.png');
@ -154,10 +146,7 @@ final class ApiControllerTest extends \PHPUnit\Framework\TestCase
self::assertEquals('Profile Logo', $image->name);
}
/**
* @covers \Modules\Profile\Controller\ApiController
* @group module
*/
#[\PHPUnit\Framework\Attributes\Group('module')]
public function testApiProfileImageSetInvalid() : void
{
$response = new HttpResponse();
@ -167,31 +156,23 @@ final class ApiControllerTest extends \PHPUnit\Framework\TestCase
self::assertEquals(RequestStatusCode::R_400, $response->header->status);
}
/**
* @covers \Modules\Profile\Controller\ApiController
* @group module
*/
/*
public function testApiContactElementCreate() : void
{
$response = new HttpResponse();
$request = new HttpRequest();
$request->header->account = 1;
$request->setData('account', '1');
$request->setData('type', ContactType::PHONE);
$request->setData('content', '+0123-456-789');
$request->setData('contact', '1');
$this->module->apiContactElementCreate($request, $response);
self::assertGreaterThan(0, $response->getDataArray('')['response']->id);
}
*/
/**
* @covers \Modules\Profile\Controller\ApiController
* @group module
*/
#[\PHPUnit\Framework\Attributes\Group('module')]
public function testApiContactElementCreateInvalidData() : void
{
$response = new HttpResponse();

View File

@ -19,6 +19,7 @@ use Modules\Profile\Models\ContactElement;
/**
* @internal
*/
#[\PHPUnit\Framework\Attributes\CoversClass(\Modules\Profile\Models\ContactElement::class)]
final class ContactElementTest extends \PHPUnit\Framework\TestCase
{
private ContactElement $contact;
@ -31,10 +32,7 @@ final class ContactElementTest extends \PHPUnit\Framework\TestCase
$this->contact = new ContactElement();
}
/**
* @covers \Modules\Profile\Models\ContactElement
* @group module
*/
#[\PHPUnit\Framework\Attributes\Group('module')]
public function testDefault() : void
{
self::assertEquals(0, $this->contact->id);

View File

@ -19,6 +19,7 @@ use Modules\Profile\Models\Contact;
/**
* @internal
*/
#[\PHPUnit\Framework\Attributes\CoversClass(\Modules\Profile\Models\Contact::class)]
final class ContactTest extends \PHPUnit\Framework\TestCase
{
private Contact $contact;
@ -31,10 +32,7 @@ final class ContactTest extends \PHPUnit\Framework\TestCase
$this->contact = new Contact();
}
/**
* @covers \Modules\Profile\Models\Contact
* @group module
*/
#[\PHPUnit\Framework\Attributes\Group('module')]
public function testDefault() : void
{
self::assertEquals(0, $this->contact->id);

View File

@ -19,31 +19,23 @@ use Modules\Profile\Models\NullContactElement;
/**
* @internal
*/
#[\PHPUnit\Framework\Attributes\CoversClass(\Modules\Profile\Models\NullContactElement::class)]
final class NullContactElementTest extends \PHPUnit\Framework\TestCase
{
/**
* @covers \Modules\Profile\Models\NullContactElement
* @group module
*/
#[\PHPUnit\Framework\Attributes\Group('module')]
public function testNull() : void
{
self::assertInstanceOf('\Modules\Profile\Models\ContactElement', new NullContactElement());
}
/**
* @covers \Modules\Profile\Models\NullContactElement
* @group module
*/
#[\PHPUnit\Framework\Attributes\Group('module')]
public function testId() : void
{
$null = new NullContactElement(2);
self::assertEquals(2, $null->id);
}
/**
* @covers \Modules\Profile\Models\NullContactElement
* @group module
*/
#[\PHPUnit\Framework\Attributes\Group('module')]
public function testJsonSerialize() : void
{
$null = new NullContactElement(2);

View File

@ -19,31 +19,23 @@ use Modules\Profile\Models\NullContact;
/**
* @internal
*/
#[\PHPUnit\Framework\Attributes\CoversClass(\Modules\Profile\Models\NullContact::class)]
final class NullContactTest extends \PHPUnit\Framework\TestCase
{
/**
* @covers \Modules\Profile\Models\NullContact
* @group module
*/
#[\PHPUnit\Framework\Attributes\Group('module')]
public function testNull() : void
{
self::assertInstanceOf('\Modules\Profile\Models\Contact', new NullContact());
}
/**
* @covers \Modules\Profile\Models\NullContact
* @group module
*/
#[\PHPUnit\Framework\Attributes\Group('module')]
public function testId() : void
{
$null = new NullContact(2);
self::assertEquals(2, $null->id);
}
/**
* @covers \Modules\Profile\Models\NullContact
* @group module
*/
#[\PHPUnit\Framework\Attributes\Group('module')]
public function testJsonSerialize() : void
{
$null = new NullContact(2);

View File

@ -19,31 +19,23 @@ use Modules\Profile\Models\NullProfile;
/**
* @internal
*/
#[\PHPUnit\Framework\Attributes\CoversClass(\Modules\Profile\Models\NullProfile::class)]
final class NullProfileTest extends \PHPUnit\Framework\TestCase
{
/**
* @covers \Modules\Profile\Models\NullProfile
* @group module
*/
#[\PHPUnit\Framework\Attributes\Group('module')]
public function testNull() : void
{
self::assertInstanceOf('\Modules\Profile\Models\Profile', new NullProfile());
}
/**
* @covers \Modules\Profile\Models\NullProfile
* @group module
*/
#[\PHPUnit\Framework\Attributes\Group('module')]
public function testId() : void
{
$null = new NullProfile(2);
self::assertEquals(2, $null->id);
}
/**
* @covers \Modules\Profile\Models\NullProfile
* @group module
*/
#[\PHPUnit\Framework\Attributes\Group('module')]
public function testJsonSerialize() : void
{
$null = new NullProfile(2);

View File

@ -23,12 +23,10 @@ use Modules\Profile\Models\ProfileMapper;
/**
* @internal
*/
#[\PHPUnit\Framework\Attributes\CoversClass(\Modules\Profile\Models\ProfileMapper::class)]
final class ProfileMapperTest extends \PHPUnit\Framework\TestCase
{
/**
* @covers \Modules\Profile\Models\ProfileMapper
* @group module
*/
#[\PHPUnit\Framework\Attributes\Group('module')]
public function testCRUD() : void
{
$media = new Media();

View File

@ -23,6 +23,7 @@ use Modules\Profile\Models\SexType;
/**
* @internal
*/
#[\PHPUnit\Framework\Attributes\CoversClass(\Modules\Profile\Models\Profile::class)]
final class ProfileTest extends \PHPUnit\Framework\TestCase
{
private Profile $profile;
@ -35,10 +36,7 @@ final class ProfileTest extends \PHPUnit\Framework\TestCase
$this->profile = new Profile();
}
/**
* @covers \Modules\Profile\Models\Profile
* @group module
*/
#[\PHPUnit\Framework\Attributes\Group('module')]
public function testDefault() : void
{
self::assertEquals(0, $this->profile->id);
@ -49,20 +47,14 @@ final class ProfileTest extends \PHPUnit\Framework\TestCase
self::assertNull($this->profile->birthday);
}
/**
* @covers \Modules\Profile\Models\Profile
* @group module
*/
#[\PHPUnit\Framework\Attributes\Group('module')]
public function testGenderInputOutput() : void
{
$this->profile->setGender(GenderType::FEMALE);
self::assertEquals(GenderType::FEMALE, $this->profile->getGender());
}
/**
* @covers \Modules\Profile\Models\Profile
* @group module
*/
#[\PHPUnit\Framework\Attributes\Group('module')]
public function testInvalidGender() : void
{
$this->expectException(\phpOMS\Stdlib\Base\Exception\InvalidEnumValue::class);
@ -70,20 +62,14 @@ final class ProfileTest extends \PHPUnit\Framework\TestCase
$this->profile->setGender(9999);
}
/**
* @covers \Modules\Profile\Models\Profile
* @group module
*/
#[\PHPUnit\Framework\Attributes\Group('module')]
public function testSexInputOutput() : void
{
$this->profile->setSex(SexType::FEMALE);
self::assertEquals(SexType::FEMALE, $this->profile->getSex());
}
/**
* @covers \Modules\Profile\Models\Profile
* @group module
*/
#[\PHPUnit\Framework\Attributes\Group('module')]
public function testInvalidSex() : void
{
$this->expectException(\phpOMS\Stdlib\Base\Exception\InvalidEnumValue::class);
@ -91,30 +77,21 @@ final class ProfileTest extends \PHPUnit\Framework\TestCase
$this->profile->setSex(9999);
}
/**
* @covers \Modules\Profile\Models\Profile
* @group module
*/
#[\PHPUnit\Framework\Attributes\Group('module')]
public function testBirthdayInputOutput() : void
{
$this->profile->birthday = ($date = new \DateTime('now'));
self::assertEquals($date, $this->profile->birthday);
}
/**
* @covers \Modules\Profile\Models\Profile
* @group module
*/
#[\PHPUnit\Framework\Attributes\Group('module')]
public function testImageInputOutput() : void
{
$this->profile->image = new NullMedia(1);
self::assertEquals(1, $this->profile->image->id);
}
/**
* @covers \Modules\Profile\Models\Profile
* @group module
*/
#[\PHPUnit\Framework\Attributes\Group('module')]
public function testAccountInputOutput() : void
{
$this->profile->account = new NullAccount(1);
@ -124,10 +101,7 @@ final class ProfileTest extends \PHPUnit\Framework\TestCase
self::assertEquals(1, $profile->account->id);
}
/**
* @covers \Modules\Profile\Models\Profile
* @group module
*/
#[\PHPUnit\Framework\Attributes\Group('module')]
public function testSerialize() : void
{
$this->profile->setGender(GenderType::FEMALE);

View File

@ -1,31 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="Bootstrap.php" colors="true" columns="120" stopOnError="true" stopOnFailure="false" stopOnIncomplete="false" stopOnSkipped="false" beStrictAboutTestsThatDoNotTestAnything="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage includeUncoveredFiles="true" processUncoveredFiles="false">
<include>
<directory suffix=".php">../</directory>
</include>
<exclude>
<directory>../vendor*</directory>
<directory>../MainRepository*</directory>
<directory>../Karaka*</directory>
<directory>../Admin/Install/Application*</directory>
<directory>../phpOMS*</directory>
<directory>../tests*</directory>
<directory>../*/tests*</directory>
<directory>../**/tests*</directory>
<directory>*/tests*</directory>
<directory suffix="tpl.php">../*</directory>
<directory suffix="lang.php">../*</directory>
<directory suffix="Test.php">../*</directory>
<directory suffix="Routes.php">../*</directory>
<directory suffix="Hooks.php">../*</directory>
<directory>../**/test*</directory>
<directory>../**/Theme*</directory>
<directory>../**/Admin/Routes*</directory>
<directory>../**/Admin/Hooks*</directory>
<directory>../**/Admin/Install*</directory>
<directory>../Media/Files*</directory>
</exclude>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="Bootstrap.php" colors="true" columns="120" stopOnError="true" stopOnFailure="false" stopOnIncomplete="false" stopOnSkipped="false" beStrictAboutTestsThatDoNotTestAnything="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.0/phpunit.xsd" cacheDirectory=".phpunit.cache">
<coverage includeUncoveredFiles="true">
<report>
<clover outputFile="coverage.xml"/>
<html outputDirectory="../tests" lowUpperBound="75" highLowerBound="95"/>
@ -56,4 +31,31 @@
<const name="WEB_SERVER_DOCROOT" value="./Karaka"/>
<const name="RESET" value="1"/>
</php>
<source>
<include>
<directory suffix=".php">../</directory>
</include>
<exclude>
<directory>../vendor*</directory>
<directory>../MainRepository*</directory>
<directory>../Karaka*</directory>
<directory>../Admin/Install/Application*</directory>
<directory>../phpOMS*</directory>
<directory>../tests*</directory>
<directory>../*/tests*</directory>
<directory>../**/tests*</directory>
<directory>*/tests*</directory>
<directory suffix="tpl.php">../*</directory>
<directory suffix="lang.php">../*</directory>
<directory suffix="Test.php">../*</directory>
<directory suffix="Routes.php">../*</directory>
<directory suffix="Hooks.php">../*</directory>
<directory>../**/test*</directory>
<directory>../**/Theme*</directory>
<directory>../**/Admin/Routes*</directory>
<directory>../**/Admin/Hooks*</directory>
<directory>../**/Admin/Install*</directory>
<directory>../Media/Files*</directory>
</exclude>
</source>
</phpunit>