Skip to content

Commit

Permalink
upgrade phpunit
Browse files Browse the repository at this point in the history
  • Loading branch information
Dennis Eichhorn committed Mar 20, 2024
1 parent 80176a5 commit 3c55705
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 138 deletions.
35 changes: 8 additions & 27 deletions tests/Controller/ApiControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
/**
* @internal
*/
#[\PHPUnit\Framework\Attributes\CoversClass(\Modules\Profile\Controller\ApiController::class)]
final class ApiControllerTest extends \PHPUnit\Framework\TestCase
{
protected ApplicationAbstract $app;
Expand Down Expand Up @@ -91,10 +92,7 @@ protected function setUp() : void
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);
Expand All @@ -110,10 +108,7 @@ public function testApiProfileCreate() : void
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();
Expand All @@ -125,10 +120,7 @@ public function testApiProfileTempLoginCreate() : void
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');
Expand All @@ -154,10 +146,7 @@ public function testApiProfileImageSet() : void
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();
Expand All @@ -167,31 +156,23 @@ public function testApiProfileImageSetInvalid() : void
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();
Expand Down
6 changes: 2 additions & 4 deletions tests/Models/ContactElementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
/**
* @internal
*/
#[\PHPUnit\Framework\Attributes\CoversClass(\Modules\Profile\Models\ContactElement::class)]
final class ContactElementTest extends \PHPUnit\Framework\TestCase
{
private ContactElement $contact;
Expand All @@ -31,10 +32,7 @@ protected function setUp() : void
$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);
Expand Down
6 changes: 2 additions & 4 deletions tests/Models/ContactTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
/**
* @internal
*/
#[\PHPUnit\Framework\Attributes\CoversClass(\Modules\Profile\Models\Contact::class)]
final class ContactTest extends \PHPUnit\Framework\TestCase
{
private Contact $contact;
Expand All @@ -31,10 +32,7 @@ protected function setUp() : void
$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);
Expand Down
16 changes: 4 additions & 12 deletions tests/Models/NullContactElementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,31 +19,23 @@
/**
* @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);
Expand Down
16 changes: 4 additions & 12 deletions tests/Models/NullContactTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,31 +19,23 @@
/**
* @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);
Expand Down
16 changes: 4 additions & 12 deletions tests/Models/NullProfileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,31 +19,23 @@
/**
* @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);
Expand Down
6 changes: 2 additions & 4 deletions tests/Models/ProfileMapperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,10 @@
/**
* @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();
Expand Down
46 changes: 10 additions & 36 deletions tests/Models/ProfileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
/**
* @internal
*/
#[\PHPUnit\Framework\Attributes\CoversClass(\Modules\Profile\Models\Profile::class)]
final class ProfileTest extends \PHPUnit\Framework\TestCase
{
private Profile $profile;
Expand All @@ -35,10 +36,7 @@ protected function setUp() : void
$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);
Expand All @@ -49,72 +47,51 @@ public function testDefault() : void
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);

$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);

$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);
Expand All @@ -124,10 +101,7 @@ public function testAccountInputOutput() : void
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);
Expand Down
Loading

0 comments on commit 3c55705

Please sign in to comment.