function ChangeLoggerTest::testChangeLogging
Tests that the requested and applied changes are logged.
File
-
core/
modules/ package_manager/ tests/ src/ Kernel/ ChangeLoggerTest.php, line 44
Class
- ChangeLoggerTest
- @covers \Drupal\package_manager\EventSubscriber\ChangeLogger @group package_manager
Namespace
Drupal\Tests\package_manager\KernelCode
public function testChangeLogging() : void {
$this->setReleaseMetadata([
'semver_test' => __DIR__ . '/../../fixtures/release-history/semver_test.1.1.xml',
]);
(new ActiveFixtureManipulator())->addPackage([
'name' => 'package/removed',
'type' => 'library',
])
->commitChanges();
$this->getStageFixtureManipulator()
->setCorePackageVersion('9.8.1')
->addPackage([
'name' => 'drupal/semver_test',
'type' => 'drupal-module',
'version' => '8.1.1',
])
->removePackage('package/removed');
$stage = $this->createStage();
$stage->create();
$stage->require([
'drupal/semver_test:*',
'drupal/core-recommended:^9.8.1',
]);
// Nothing should be logged until post-apply.
$stage->apply();
$this->assertEmpty($this->logger->records);
$stage->postApply();
$this->assertTrue($this->logger
->hasInfoRecords());
$records = $this->logger->recordsByLevel[LogLevel::INFO];
$this->assertCount(2, $records);
// The first record should be of the requested changes.
$expected_message = <<<END
Requested changes:
- Update drupal/core-recommended from 9.8.0 to ^9.8.1
- Install drupal/semver_test * (any version)
END;
$this->assertSame($expected_message, (string) $records[0]['message']);
// The second record should be of the actual changes.
$expected_message = <<<END
Applied changes:
- Updated drupal/core from 9.8.0 to 9.8.1
- Updated drupal/core-dev from 9.8.0 to 9.8.1
- Updated drupal/core-recommended from 9.8.0 to 9.8.1
- Installed drupal/semver_test 8.1.1
- Uninstalled package/removed
END;
$this->assertSame($expected_message, (string) $records[1]['message']);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.