Skip to content
Open
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
12 changes: 6 additions & 6 deletions components/ILIAS/Authentication/tests/LocalUserPasswordTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public function testPasswordManagerEncodesRawPasswordWithSalt(): void
$encoder = $this->getMockBuilder(ilBasePasswordEncoder::class)->disableOriginalConstructor()->getMock();
$factory_mock = $this->getMockBuilder(LocalUserPasswordEncoderFactory::class)->disableOriginalConstructor()->getMock();

$user_mock->expects($this->once())->method('setPasswordSalt')->with($this->isType('string'));
$user_mock->expects($this->once())->method('setPasswordSalt')->with($this->isString());
$user_mock->expects($this->once())->method('getPasswordSalt')->willReturn('asuperrandomsalt');
$user_mock->expects($this->once())->method('setPasswordEncodingType')->with($this->equalTo('mockencoder'));
$user_mock->expects($this->once())->method('setPasswd')->with(
Expand All @@ -155,7 +155,7 @@ public function testPasswordManagerEncodesRawPasswordWithSalt(): void
$encoder->expects($this->once())->method('encodePassword')
->with(
$this->equalTo(self::PASSWORD),
$this->isType('string')
$this->isString()
)->willReturn(self::ENCODED_PASSWORD)
;

Expand Down Expand Up @@ -225,7 +225,7 @@ public function testPasswordManagerVerifiesPassword(): void
$encoder->expects($this->once())->method('isPasswordValid')->with(
$this->equalTo(self::ENCODED_PASSWORD),
$this->equalTo(self::PASSWORD),
$this->isType('string')
$this->isString()
)->willReturn(true);
$encoder->expects($this->once())->method('requiresReencoding')
->with($this->equalTo(self::ENCODED_PASSWORD))
Expand Down Expand Up @@ -264,7 +264,7 @@ public function testPasswordManagerMigratesPasswordOnVerificationWithVariantEnco
$encoder->expects($this->once())->method('isPasswordValid')->with(
$this->equalTo(self::ENCODED_PASSWORD),
$this->equalTo(self::PASSWORD),
$this->isType('string')
$this->isString()
)->willReturn(true);
$encoder->expects($this->never())->method('requiresReencoding')
->with($this->equalTo(self::ENCODED_PASSWORD))
Expand Down Expand Up @@ -303,7 +303,7 @@ public function testPasswordManagerReencodesPasswordIfReencodingIsNecessary(): v
$encoder->expects($this->once())->method('isPasswordValid')->with(
$this->equalTo(self::ENCODED_PASSWORD),
$this->equalTo(self::PASSWORD),
$this->isType('string')
$this->isString()
)->willReturn(true);
$encoder->expects($this->once())->method('requiresReencoding')
->with($this->equalTo(self::ENCODED_PASSWORD))
Expand Down Expand Up @@ -342,7 +342,7 @@ public function testPasswordManagerNeverMigratesPasswordOnFailedVerificationWith
->with(
$this->equalTo(self::ENCODED_PASSWORD),
$this->equalTo(self::PASSWORD),
$this->isType('string')
$this->isString()
)->willReturn(false)
;

Expand Down
2 changes: 1 addition & 1 deletion components/ILIAS/Authentication/tests/ilSessionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ function ($arg) {
);

$cron_manager = $this->createMock(\ILIAS\Cron\Job\JobManager::class);
$cron_manager->method('isJobActive')->with($this->isType('string'))->willReturn(true);
$cron_manager->method('isJobActive')->with($this->isString())->willReturn(true);
$this->setGlobalVariable(
'cron.manager',
$cron_manager
Expand Down
1 change: 0 additions & 1 deletion components/ILIAS/Badge/tests/BadgeParentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ public function testShowWithoutParentReadRight(): void
$legacy = $this->getMockBuilder(Legacy\Content::class)->disableOriginalConstructor()->getMock();
$legacy_factory = $this->getMockBuilder(Legacy\Factory::class)->disableOriginalConstructor()->getMock();
$listing = $this->getMockBuilder(Listing::class)->disableOriginalConstructor()->getMock();
$parent_link = $this->getMockBuilder(Content::class)->disableOriginalConstructor()->getMock();
$renderer = $this->getMockBuilder(Renderer::class)->disableOriginalConstructor()->getMock();
$ui = $this->getMockBuilder(UIServices::class)->disableOriginalConstructor()->getMock();

Expand Down
2 changes: 0 additions & 2 deletions components/ILIAS/Component/src/Dependencies/Reader.php
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,6 @@ public function dummy()
return $mock_builder
->disableOriginalConstructor()
->disableOriginalClone()
->disableArgumentCloning()
->disallowMockingUnknownTypes()
->getMock();
}
}
7 changes: 3 additions & 4 deletions components/ILIAS/Data/tests/Description/DListTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
use ILIAS\Data\Description\DValue;
use ILIAS\Data\Description\DList;
use PHPUnit\Framework\TestCase;
use PHPUnit\Framework\Attributes\DataProvider;

class DListTest extends TestCase
{
Expand All @@ -43,9 +44,7 @@ public function setUp(): void
);
}

/**
* @dataProvider obviousNoMatchProvider
*/
#[DataProvider('obviousNoMatchProvider')]
public function testObviouslyNotMatching($data): void
{
$res = $this->l->getPrimitiveRepresentation($data);
Expand Down Expand Up @@ -113,7 +112,7 @@ public function testRenumbersEntrys(): void

$this->v
->method("getPrimitiveRepresentation")
->will($this->returnCallback(fn($v) => $v));
->willReturnCallback(fn($v) => $v);

$res = $this->l->getPrimitiveRepresentation($data);

Expand Down
5 changes: 2 additions & 3 deletions components/ILIAS/Data/tests/Description/DMapTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
use ILIAS\Data\Description\DValue;
use ILIAS\Data\Description\DMap;
use PHPUnit\Framework\TestCase;
use PHPUnit\Framework\Attributes\DataProvider;

class DMapTest extends TestCase
{
Expand All @@ -46,9 +47,7 @@ public function setUp(): void
);
}

/**
* @dataProvider obviousNoMatchProvider
*/
#[DataProvider('obviousNoMatchProvider')]
public function testObviouslyNotMatching($data): void
{
$res = $this->m->getPrimitiveRepresentation($data);
Expand Down
13 changes: 4 additions & 9 deletions components/ILIAS/Data/tests/Description/DObjectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,11 @@
use ILIAS\Data\Description\DObject;
use ILIAS\Data\Description\Field;
use PHPUnit\Framework\TestCase;
use PHPUnit\Framework\Attributes\DataProvider;

class DObjectTest extends TestCase
{
/**
* @dataProvider simpleObjectsProvider
*/
#[DataProvider('simpleObjectsProvider')]
public function testSimpleObject(string $field, $object, $expected): void
{
$md = $this->createMock(\ILIAS\Data\Text\SimpleDocumentMarkdown::class);
Expand Down Expand Up @@ -103,9 +102,7 @@ public function getSomeValue(): int
];
}

/**
* @dataProvider fieldNamesProvider
*/
#[DataProvider('fieldNamesProvider')]
public function testAllowedFieldNames(string $name, bool $is_allowed): void
{
if (!$is_allowed) {
Expand All @@ -128,9 +125,7 @@ public static function fieldNamesProvider(): array
];
}

/**
* @dataProvider obviousNoMatchProvider
*/
#[DataProvider('obviousNoMatchProvider')]
public function testObviouslyNotMatching($data): void
{
$desc = new DObject(
Expand Down
5 changes: 2 additions & 3 deletions components/ILIAS/Data/tests/Description/DValueTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,11 @@
use ILIAS\Data\Description\DValue;
use ILIAS\Data\Description\ValueType;
use PHPUnit\Framework\TestCase;
use PHPUnit\Framework\Attributes\DataProvider;

class DDValueTest extends TestCase
{
/**
* @dataProvider casesProvider
*/
#[DataProvider('casesProvider')]
public function testIntRepresentation(ValueType $type, $value, $is_match): void
{
$desc = new DValue(
Expand Down
14 changes: 6 additions & 8 deletions components/ILIAS/EventHandling/tests/EventTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,12 @@ protected function setUp(): void

$db_mock = $this->createMock(ilDBInterface::class);
$db_mock->method("fetchAssoc")
->will(
$this->onConsecutiveCalls(
[
"component" => "components/ILIAS/EventHandling",
"id" => "MyTestComponent"
],
null
)
->willReturnOnConsecutiveCalls(
[
"component" => "components/ILIAS/EventHandling",
"id" => "MyTestComponent"
],
null
);


Expand Down
2 changes: 1 addition & 1 deletion components/ILIAS/Forum/tests/ilForumTopicTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
use ILIAS\DI\Container;
use PHPUnit\Framework\TestCase;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\MockObject\Builder\InvocationMocker;
use PHPUnit\Framework\MockObject\InvocationMocker;

class ilForumTopicTest extends TestCase
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public function testRepoAccessTrueNotLoggedInPublicSection(): void

$access_mock->expects($this->once())
->method('checkAccessOfUser')
->with($this->isType('integer'), 'read', '', $this->ROOT_FOLDER_ID)
->with($this->isInt(), 'read', '', $this->ROOT_FOLDER_ID)
->willReturn(true);

$this->assertTrue($class->isRepositoryReadable()());
Expand Down
10 changes: 4 additions & 6 deletions components/ILIAS/LearningSequence/tests/IliasMocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ protected function mockUIFactory(): UIFactory
{
$ui_reflection = new ReflectionClass(UIFactory::class);
$methods = array_map(
fn ($m) => $m->getName(),
fn($m) => $m->getName(),
$ui_reflection->getMethods()
);

Expand All @@ -50,11 +50,9 @@ protected function mockUIFactory(): UIFactory
$ui_factory->method('viewControl')
->willReturn(new CImpl\ViewControl\Factory($signal_generator));
$ui_factory->method('breadcrumbs')
->will(
$this->returnCallback(function ($crumbs) {
return new CImpl\Breadcrumbs\Breadcrumbs($crumbs);
})
);
->willReturnCallback(function ($crumbs) {
return new CImpl\Breadcrumbs\Breadcrumbs($crumbs);
});
$ui_factory->method('link')
->willReturn(new CImpl\Link\Factory());
$ui_factory->method('symbol')
Expand Down
4 changes: 2 additions & 2 deletions components/ILIAS/LegalDocuments/tests/WiringTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ public function testHasPublicPage(): void

$instance = new Wiring(
$this->mockTree(SlotConstructor::class, ['id' => 'foo']),
$this->mockMethod(Map::class, 'set', ['public-page', 'foo', $public_page], $map)
$this->mockMethod(Map::class, 'set', ['public-page', 'foo'], $map)
);

$this->assertSame($map, $instance->hasPublicPage($public_page)->map());
Expand All @@ -218,7 +218,7 @@ public function testHasPublicPageWithGotoLink(): void

$instance = new Wiring(
$this->mockTree(SlotConstructor::class, ['id' => 'foo']),
$this->mockMethod(Map::class, 'set', ['public-page', 'foo', $public_page], $map)
$this->mockMethod(Map::class, 'set', ['public-page', 'foo'], $map)
);

$this->assertSame($m, $instance->hasPublicPage($public_page, 'foo')->map());
Expand Down
4 changes: 2 additions & 2 deletions components/ILIAS/Mail/tests/RecipientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function testCheckProperties(): void
$this->assertFalse($recipient->onlyToExternalMailAddress());
$this->assertIsArray($recipient->getExternalMailAddress());
$this->assertCount(2, $recipient->getExternalMailAddress());
$this->assertContainsOnly('string', $recipient->getExternalMailAddress());
array_map($this->assertIsString(...), $recipient->getExternalMailAddress());
}

public function testPropertiesPart2(): void
Expand Down Expand Up @@ -125,6 +125,6 @@ public function testPropertiesPart2(): void
$this->assertFalse($recipient->onlyToExternalMailAddress());
$this->assertIsArray($recipient->getExternalMailAddress());
$this->assertCount(2, $recipient->getExternalMailAddress());
$this->assertContainsOnly('string', $recipient->getExternalMailAddress());
array_map($this->assertIsString(...), $recipient->getExternalMailAddress());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ public function testSubscribersCanBeRetrieved(): void
$this->assertStringContainsString(array_shift($consecutive), $value);
return true;
}),
$this->isType('array'),
$this->isType('array')
$this->isArray(),
$this->isArray()
)
->willReturn($resultMock);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public static function latin1StringProvider(): array
for ($j = 0; $j < $length; $j++) {
$string .= chr(random_int(0, 255));
}
$strings[] = [$string, @utf8_encode($string)]; // we must suppress the deprecation warning here
$strings[] = [$string, mb_convert_encoding($string, 'UTF-8', 'ISO-8859-1')];
}
return $strings;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public static function definitionsToMachines(): \Iterator


#[DataProvider('definitionsToMachines')]
public function testDefaultMachines(FlavourDefinition $d, string $machine): void
public function testDefaultMachines(FlavourDefinition $d, string $machine, string $engine): void
{
$factory = new Factory($this->engine_factory_mock);
$this->engine_factory_mock->expects($this->once())
Expand Down
7 changes: 1 addition & 6 deletions components/ILIAS/Setup/Setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,9 @@ public function init(
);

$internal["config_reader"] = static fn() =>
new \ILIAS\Setup\CLI\ConfigReader(
$internal["json.parser"]
);
new \ILIAS\Setup\CLI\ConfigReader();

$internal["interface_finder"] = static fn() =>
new \ILIAS\Setup\ImplementationOfInterfaceFinder();

$internal["json.parser"] = static fn() =>
new \Seld\JsonLint\JsonParser();
}
}
11 changes: 5 additions & 6 deletions components/ILIAS/Setup/src/CLI/ConfigReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,16 @@
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Seld\JsonLint\JsonParser;

/**
* Read a json-formatted config from a file and overwrite some fields.
*/
class ConfigReader
{
protected JsonParser $json_parser;
protected string $base_dir;

public function __construct(JsonParser $json_parser, ?string $base_dir = null)
public function __construct(?string $base_dir = null)
{
$this->json_parser = $json_parser;
$this->base_dir = $base_dir ?? getcwd();
}

Expand All @@ -60,9 +57,11 @@ public function readConfigFile(string $name, array $overwrites = []): array
"Config-file '$name' does not exist or is not readable."
);
}
$json = $this->json_parser->parse(
$json = json_decode(
file_get_contents($name),
JsonParser::PARSE_TO_ASSOC | JsonParser::DETECT_KEY_CONFLICTS
true,
512,
JSON_THROW_ON_ERROR
);

if (!is_array($json)) {
Expand Down
4 changes: 2 additions & 2 deletions components/ILIAS/Setup/tests/AgentCollectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -473,10 +473,10 @@ public function testGetNamedObjectivePassesCorrectConfig()
$seen_config = null;
$agent
->method("getNamedObjectives")
->will($this->returnCallback(function ($config) use (&$seen_config) {
->willReturnCallback(function ($config) use (&$seen_config) {
$seen_config = $config;
return [];
}));
});

$collection = new Setup\AgentCollection(
$refinery,
Expand Down
4 changes: 2 additions & 2 deletions components/ILIAS/Setup/tests/CLI/AchieveCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ public function testAchieveObjective(): void
$agent
->expects($this->once())
->method("getNamedObjectives")
->will($this->returnCallback(function ($config) use (&$seen_config, $objective) {
->willReturnCallback(function ($config) use (&$seen_config, $objective) {
$seen_config = $config;
return [
"my.objective" => new Setup\ObjectiveConstructor(
Expand All @@ -233,7 +233,7 @@ static function () use ($objective): Setup\Objective {
}
)
];
}));
});

$objective
->expects($this->once())
Expand Down
4 changes: 2 additions & 2 deletions components/ILIAS/Setup/tests/CLI/BuildCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ public function testBasicFunctionality(): void
$objective
->expects($this->once())
->method("achieve")
->will($this->returnCallback(function (Setup\Environment $e) {
->willReturnCallback(function (Setup\Environment $e) {
return $e;
}));
});

$objective
->expects($this->once())
Expand Down
Loading
Loading