8use PHPUnit\Framework\MockObject\MockObject;
 
    9use PHPUnit\Framework\TestCase;
 
   17        $environment = $this->createMock(Setup\Environment::class);
 
   20            ->expects($this->once())
 
   21            ->method(
"getPreconditions")
 
   27        $this->assertTrue($iterator->valid());
 
   28        $this->assertSame($objective, $iterator->current());
 
   29        $this->assertSame($hash, $iterator->key());
 
   33        $this->assertFalse($iterator->valid());
 
   40        $environment = $this->createMock(Setup\Environment::class);
 
   45            ->expects($this->once())
 
   46            ->method(
"getPreconditions")
 
   53        $this->assertTrue($iterator->valid());
 
   54        $this->assertSame($objective, $iterator->current());
 
   55        $this->assertSame($hash, $iterator->key());
 
   60        $environment = $this->createMock(Setup\Environment::class);
 
   68            ->method(
"getPreconditions")
 
   70            ->willReturn([$objective11, $objective12]);
 
   73            ->method(
"getPreconditions")
 
   78            ->method(
"getPreconditions")
 
   80            ->willReturn([$objective121]);
 
   83            ->method(
"getPreconditions")
 
   90            $objective11->getHash() => $objective11,
 
   91            $objective121->getHash() => $objective121,
 
   92            $objective12->getHash() => $objective12,
 
   93            $objective1->getHash() => $objective1
 
   96        $this->assertEquals($expected, iterator_to_array($iterator));
 
  101        $environment = $this->createMock(Setup\Environment::class);
 
  107            ->method(
"getPreconditions")
 
  109            ->willReturn([$objective11, $objective11]);
 
  112            ->method(
"getPreconditions")
 
  119            $objective11->getHash() => $objective11,
 
  120            $objective1->getHash() => $objective1
 
  122        $this->assertEquals($expected, iterator_to_array($iterator));
 
  127        $environment = $this->createMock(Setup\Environment::class);
 
  133            ->method(
"getPreconditions")
 
  135            ->willReturn([$objective2]);
 
  138            ->method(
"getPreconditions")
 
  140            ->willReturn([$objective1]);
 
  142        $this->expectException(Setup\UnachievableException::class);
 
  145        iterator_to_array($iterator);
 
  157            ->expects($this->atLeastOnce())
 
  158            ->method(
"getPreconditions")
 
  160            ->willReturn([$objective2]);
 
  163            ->expects($this->atLeastOnce())
 
  164            ->method(
"getPreconditions")
 
  170        $iterator->setEnvironment($env2);
 
  176        $this->expectException(Setup\UnachievableException::class);
 
  186            ->method(
"getPreconditions")
 
  190            ->method(
"getPreconditions")
 
  194            ->method(
"getPreconditions")
 
  195            ->willReturn([$objective_1, $objective_fail, $objective_2]);
 
  200        $this->assertEquals($objective_1, $iterator->current());
 
  202        $this->assertEquals($objective_fail, $iterator->current());
 
  203        $iterator->markAsFailed($objective_fail);
 
  205        $this->assertEquals($objective_2, $iterator->current());
 
  214            ->getMockBuilder(Setup\Objective::class)
 
  215            ->setMethods([
"getHash", 
"getLabel", 
"isNotable", 
"withResourcesFrom", 
"getPreconditions", 
"achieve", 
"isApplicable"])
 
  216            ->setMockClassName(
"Mock_ObjectiveNo" . ($no++))
 
  221            ->willReturn($hash ?? 
"" . $no);
 
  228        $this->expectException(Setup\UnachievableException::class);
 
  238            ->method(
"getPreconditions")
 
  239            ->willReturn([$objective_fail]);
 
  241            ->method(
"getPreconditions")
 
  244            ->method(
"getPreconditions")
 
  245            ->willReturn([$objective_1, $objective_2]);
 
  247        $iterator = 
new class($env, $objective_3, $objective_fail) extends Setup\
ObjectiveIterator {
 
  251                MockObject $objective_fail
 
  254                $this->failed[$objective_fail->getHash()] = 
true;
 
  258        $this->assertEquals($objective_fail, $iterator->current());
 
  265        $this->expectException(Setup\UnachievableException::class);
 
  274            ->method(
"getPreconditions")
 
  275            ->willReturn([$objective_fail]);
 
  277            ->method(
"getPreconditions")
 
  278            ->willReturn([$objective_1]);
 
  280        $iterator = 
new class($env, $objective_2, $objective_fail) extends Setup\
ObjectiveIterator {
 
  284                MockObject $objective_fail
 
  287                $this->failed[$objective_fail->getHash()] = 
true;
 
  291        $this->assertEquals($objective_fail, $iterator->current());
 
An exception for terminatinating execution or to throw for unit testing.
Tries to enumerate all preconditions for the given objective, where the ones that can be achieved (i....
testAllObjectivesOnlyReturnsObjectiveOnce()
testAllObjectivesDetectsCycle()
testFailedPreconditionLastOnStack()
testFailedPreconditionWithOtherOnStack()
__construct($a_client_id=0)
Constructor setup ILIAS global object @access public.
An environment holds resources to be used in the setup process.
An objective is a desired state of the system that is supposed to be created by the setup.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...