private function SchedulerMultilingualTest::checkStatus in Scheduler 8
Same name and namespace in other branches
- 2.x tests/src/Functional/SchedulerMultilingualTest.php \Drupal\Tests\scheduler\Functional\SchedulerMultilingualTest::checkStatus()
Helper function to assert the published status of translations.
Parameters
int $nid: The node id of the node to check.
string $description: Text explaining what part of the test is being checked.
array $status: Array of expected status values for the translations. The original content status is first, followed by any number of translations.
1 call to SchedulerMultilingualTest::checkStatus()
- SchedulerMultilingualTest::testPublishingTranslations in tests/
src/ Functional/ SchedulerMultilingualTest.php - Test creating translations with independent scheduling.
File
- tests/
src/ Functional/ SchedulerMultilingualTest.php, line 99
Class
- SchedulerMultilingualTest
- Tests the scheduling functions for node translations.
Namespace
Drupal\Tests\scheduler\FunctionalCode
private function checkStatus($nid, $description, array $status) {
// Reset the cache and reload the node.
$this->nodeStorage
->resetCache([
$nid,
]);
$node = $this->nodeStorage
->load($nid);
foreach ($status as $key => $expected_status) {
if ($key == 0) {
// Key 0 is the original, so we just check $node.
$this
->assertEquals($expected_status, $node
->isPublished(), sprintf('%s: The original content (%s) is %s', $description, $this->languages[$key]['name'], $expected_status ? 'published' : 'unpublished'));
}
else {
// Key > 0 are the translations.
$translation = $node
->getTranslation($this->languages[$key]['code']);
$this
->assertEquals($expected_status, $translation
->isPublished(), sprintf('%s: Translation %d (%s) is %s', $description, $key, $this->languages[$key]['name'], $expected_status ? 'published' : 'unpublished'));
}
}
}