class LoggingBeginnerTest

@covers \Drupal\package_manager\LoggingBeginner @group package_manager

Hierarchy

Expanded class hierarchy of LoggingBeginnerTest

File

core/modules/package_manager/tests/src/Unit/LoggingBeginnerTest.php, line 19

Namespace

Drupal\Tests\package_manager\Unit
View source
class LoggingBeginnerTest extends UnitTestCase {
    public function testDecoratedBeginnerIsCalled() : void {
        $decorated = $this->createMock(BeginnerInterface::class);
        $activeDir = $this->createMock(PathInterface::class);
        $stagingDir = $this->createMock(PathInterface::class);
        $stagingDir->expects($this->any())
            ->method('absolute')
            ->willReturn('staging-dir');
        $decorated->expects($this->once())
            ->method('begin')
            ->with($activeDir, $stagingDir, NULL, $this->isInstanceOf(FileProcessOutputCallback::class));
        $config_factory = $this->getConfigFactoryStub([
            'package_manager.settings' => [
                'log' => 'php://memory',
            ],
        ]);
        $time = $this->createMock(TimeInterface::class);
        $time->expects($this->atLeast(2))
            ->method('getCurrentMicroTime')
            ->willReturnOnConsecutiveCalls(1, 2.5);
        $callback = new ProcessOutputCallback();
        (new LoggingBeginner($decorated, $config_factory, $time))->begin($activeDir, $stagingDir, callback: $callback);
        $this->assertSame([
            "### Beginning in staging-dir\n",
            "### Finished in 1.500 seconds\n",
        ], $callback->getOutput());
    }

}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.