ci(tests): Remove abstract mocks

Signed-off-by: Rubén D <nuxsmin@syspass.org>
This commit is contained in:
Rubén D
2024-03-17 09:01:18 +01:00
parent 94d5c3c944
commit 0e228f3a76
5 changed files with 28 additions and 24 deletions

View File

@@ -130,7 +130,7 @@ class AccountAdapterTest extends UnitaryTestCase
public function testIncludeCustomFields(): void
{
$customFieldData = CustomFieldGenerator::factory()->buildSimpleModel();
$customFieldsService = $this->createStub(CustomFieldDataService::class);
$customFieldsService = $this->createMock(CustomFieldDataService::class);
$customFieldsService->expects(self::once())
->method('getBy')
->willReturn([$customFieldData]);

View File

@@ -64,17 +64,17 @@ use SPT\UnitaryTestCase;
*/
class AccountTest extends UnitaryTestCase
{
private AccountRepository|MockObject $accountRepository;
private AccountRepository|MockObject $accountRepository;
private AccountToUserGroupRepository|MockObject $accountToUserGroupRepository;
private AccountToUserRepository|MockObject $accountToUserRepository;
private AccountToUserRepository|MockObject $accountToUserRepository;
private AccountToTagRepository|MockObject $accountToTagRepository;
private ItemPresetService|MockObject $itemPresetService;
private AccountHistoryService|MockObject $accountHistoryService;
private ConfigService|MockObject $configService;
private AccountCryptService|MockObject $accountCryptService;
private AccountPresetService|MockObject $accountPresetService;
private AccountItemsService|MockObject $accountItemsService;
private Account $account;
private ItemPresetService|MockObject $itemPresetService;
private AccountHistoryService|MockObject $accountHistoryService;
private ConfigService|MockObject $configService;
private AccountCryptService|MockObject $accountCryptService;
private AccountPresetService|MockObject $accountPresetService;
private AccountItemsService|MockObject $accountItemsService;
private Account $account;
/**
* @throws ServiceException
@@ -1325,7 +1325,12 @@ class AccountTest extends UnitaryTestCase
{
parent::setUp();
$this->accountRepository = $this->getMockForAbstractClass(AccountRepositoryStub::class);
$accountRepositoryMethods = array_filter(
get_class_methods(AccountRepositoryStub::class),
static fn(string $method) => $method != 'transactionAware'
);
$this->accountRepository = $this->createPartialMock(AccountRepositoryStub::class, $accountRepositoryMethods);
$this->accountToUserGroupRepository = $this->createMock(AccountToUserGroupRepository::class);
$this->accountToUserRepository = $this->createMock(AccountToUserRepository::class);
$this->accountToTagRepository = $this->createMock(AccountToTagRepository::class);

View File

@@ -82,8 +82,13 @@ class UpgradePublicLinkTest extends UnitaryTestCase
{
parent::setUp();
$publicLinkRepositoryMethods = array_filter(
get_class_methods(PublicLinkRepositoryStub::class),
static fn(string $method) => $method != 'transactionAware'
);
$this->publicLinkRepository =
$this->getMockForAbstractClass(PublicLinkRepositoryStub::class);
$this->createPartialMock(PublicLinkRepositoryStub::class, $publicLinkRepositoryMethods);
$this->upgradePublicLinkService = new UpgradePublicLink($this->application, $this->publicLinkRepository);
}

View File

@@ -58,8 +58,6 @@ class XmlAccountExportTest extends UnitaryTestCase
$account = AccountDataGenerator::factory()->buildAccount();
$tag = new Item(['id' => self::$faker->randomNumber(3)]);
$document = new DOMDocument();
$this->accountService
->expects(self::once())
->method('getAllBasic')
@@ -107,8 +105,6 @@ class XmlAccountExportTest extends UnitaryTestCase
*/
public function testExportWithoutAccounts()
{
$document = new DOMDocument();
$this->accountService
->expects(self::once())
->method('getAllBasic')
@@ -130,8 +126,6 @@ class XmlAccountExportTest extends UnitaryTestCase
*/
public function testExportWithException()
{
$document = new DOMDocument();
$this->accountService
->expects(self::once())
->method('getAllBasic')

View File

@@ -88,7 +88,7 @@ final class AccountDataGenerator extends DataGenerator
'passDateChange' => $this->faker->unixTime(),
'parentId' => $this->faker->randomNumber(3),
'publicLinkHash' => $this->faker->sha1(),
'pass' => $this->faker->password(),
'pass' => $this->faker->sha1(),
'key' => $this->faker->sha1(),
];
}
@@ -153,9 +153,9 @@ final class AccountDataGenerator extends DataGenerator
login: $this->faker->userName(),
clientId: $this->faker->randomNumber(3),
categoryId: $this->faker->randomNumber(3),
pass: $this->faker->password(),
pass: $this->faker->sha1(),
userId: $this->faker->randomNumber(3),
key: $this->faker->password(),
key: $this->faker->sha1(),
url: $this->faker->url(),
notes: $this->faker->text(),
userEditId: $this->faker->randomNumber(3),
@@ -181,7 +181,7 @@ final class AccountDataGenerator extends DataGenerator
login: $this->faker->userName(),
clientId: $this->faker->randomNumber(3),
categoryId: $this->faker->randomNumber(3),
pass: $this->faker->password(),
pass: $this->faker->sha1(),
userId: $this->faker->randomNumber(3),
url: $this->faker->url(),
notes: $this->faker->text(),
@@ -216,9 +216,9 @@ final class AccountDataGenerator extends DataGenerator
login: $this->faker->userName(),
clientId: $this->faker->randomNumber(3),
categoryId: $this->faker->randomNumber(3),
pass: $this->faker->password(),
pass: $this->faker->sha1(),
userId: $this->faker->randomNumber(3),
key: $this->faker->password(),
key: $this->faker->sha1(),
url: $this->faker->url(),
notes: $this->faker->text(),
userEditId: $this->faker->randomNumber(3),