Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
phpunitCodeQuality: true,
)
->withSets([
PHPUnitSetList::PHPUNIT_100,
PHPUnitSetList::PHPUNIT_110,
])
->withPhpSets(
php82: true,
Expand Down
9 changes: 4 additions & 5 deletions tests/Unit/Activity/ProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use OCP\ILogger;
use OCP\IURLGenerator;
use OCP\L10N\IFactory;
use PHPUnit\Framework\Attributes\DataProvider;

class ProviderTest extends TestCase {
private $l10n;
Expand Down Expand Up @@ -44,19 +45,17 @@ public function testParseUnrelated(): void {
$this->provider->parse($lang, $event);
}

public function subjectData(): \Iterator {
public static function subjectData(): \Iterator {
yield ['totp_enabled_subject'];
yield ['totp_disabled_subject'];
yield ['totp_disabled_by_admin'];
}

/**
* @dataProvider subjectData
*/
#[DataProvider('subjectData')]
public function testParse($subject): void {
$lang = 'ru';
$event = $this->createMock(IEvent::class);
$l = $this->createMock(IL10N::class);
$l = $this->createStub(IL10N::class);

$event->expects($this->once())
->method('getApp')
Expand Down
10 changes: 5 additions & 5 deletions tests/Unit/Controller/SettingsControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ protected function setUp(): void {
}

public function testDisabledState(): void {
$user = $this->createMock(IUser::class);
$user = $this->createStub(IUser::class);
$this->userSession->expects($this->once())
->method('getUser')
->willReturn($user);
Expand Down Expand Up @@ -65,7 +65,7 @@ public function testCreateSecret(): void {
->method('createSecret')
->with($user)
->willReturn('newsecret');
$issuer = rawurlencode($this->defaults->getName());
$issuer = rawurlencode((string)$this->defaults->getName());
$expected = new JSONResponse([
'state' => ITotp::STATE_CREATED,
'secret' => 'newsecret',
Expand All @@ -76,7 +76,7 @@ public function testCreateSecret(): void {
}

public function testEnableSecret(): void {
$user = $this->createMock(IUser::class);
$user = $this->createStub(IUser::class);
$this->userSession->expects($this->once())
->method('getUser')
->willReturn($user);
Expand All @@ -93,7 +93,7 @@ public function testEnableSecret(): void {
}

public function testDisableSecret(): void {
$user = $this->createMock(IUser::class);
$user = $this->createStub(IUser::class);
$this->userSession->expects($this->once())
->method('getUser')
->willReturn($user);
Expand All @@ -108,7 +108,7 @@ public function testDisableSecret(): void {
}

public function testEnableInvalidState(): void {
$user = $this->createMock(IUser::class);
$user = $this->createStub(IUser::class);
$this->userSession->expects($this->once())
->method('getUser')
->willReturn($user);
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/Event/StateChangedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

class StateChangedTest extends TestCase {
public function testEnabled(): void {
$user = $this->createMock(IUser::class);
$user = $this->createStub(IUser::class);
$event = new StateChanged($user, true);

$enabled = $event->isEnabled();
Expand All @@ -24,7 +24,7 @@ public function testEnabled(): void {
}

public function testDisabled(): void {
$user = $this->createMock(IUser::class);
$user = $this->createStub(IUser::class);
$event = new StateChanged($user, false);

$enabled = $event->isEnabled();
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/Listener/StateChangeRegistryUpdaterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function testIgnoresGenericEvent(): void {
}

public function testProviderEnabledEvent(): void {
$user = $this->createMock(IUser::class);
$user = $this->createStub(IUser::class);
$event = new StateChanged($user, true);
$this->registry->expects($this->once())
->method('enableProviderFor')
Expand All @@ -56,7 +56,7 @@ public function testProviderEnabledEvent(): void {
}

public function testProviderDisabledEvent(): void {
$user = $this->createMock(IUser::class);
$user = $this->createStub(IUser::class);
$event = new StateChanged($user, false);
$this->registry->expects($this->once())
->method('disableProviderFor')
Expand Down
12 changes: 6 additions & 6 deletions tests/Unit/Provider/TotpProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public function testGetDarkIcon(): void {
public function testGetPersonalSettings(): void {
$expected = new Personal();

$user = $this->createMock(IUser::class);
$user = $this->createStub(IUser::class);
$this->totp->expects($this->once())
->method('hasSecret')
->with($user)
Expand All @@ -131,7 +131,7 @@ public function testGetPersonalSettings(): void {
}

public function testVerifyChallengeSecretNotFound(): void {
$user = $this->createMock(IUser::class);
$user = $this->createStub(IUser::class);
$this->totp->expects($this->once())
->method('getSecret')
->with($user)
Expand All @@ -143,7 +143,7 @@ public function testVerifyChallengeSecretNotFound(): void {
}

public function testVerifyChallengeStripNonDigits(): void {
$user = $this->createMock(IUser::class);
$user = $this->createStub(IUser::class);
$secret = new TotpSecret();
$this->totp->expects(self::once())
->method('getSecret')
Expand All @@ -160,7 +160,7 @@ public function testVerifyChallengeStripNonDigits(): void {
}

public function testDeactivate(): void {
$user = $this->createMock(IUser::class);
$user = $this->createStub(IUser::class);
$this->totp->expects($this->once())
->method('deleteSecret')
->with($user);
Expand All @@ -170,8 +170,8 @@ public function testDeactivate(): void {

public function testGetSetupProvider(): void {
/** @var IUser|MockObject $user */
$user = $this->createMock(IUser::class);
$provider = $this->createMock(AtLoginProvider::class);
$user = $this->createStub(IUser::class);
$provider = $this->createStub(AtLoginProvider::class);
$this->container->expects($this->once())
->method('query')
->with(AtLoginProvider::class)
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
-->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
bootstrap="bootstrap.php"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd">
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.5/phpunit.xsd">
<source>
<include>
<directory suffix=".php">../lib</directory>
Expand Down
9 changes: 7 additions & 2 deletions vendor-bin/phpunit/composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
{
"config": {
"platform": {
"php": "8.2"
}
},
"require-dev": {
"christophwurst/nextcloud_testing": "^1.1.3",
"phpunit/phpunit": "^10"
"christophwurst/nextcloud_testing": "^2",
"phpunit/phpunit": "^11"
}
}
Loading
Loading