class AlertsJsonFeedTest
Same name in this branch
- 11.x core/modules/announcements_feed/tests/src/FunctionalJavascript/AlertsJsonFeedTest.php \Drupal\Tests\announcements_feed\FunctionalJavascript\AlertsJsonFeedTest
Same name and namespace in other branches
- 10 core/modules/announcements_feed/tests/src/FunctionalJavascript/AlertsJsonFeedTest.php \Drupal\Tests\announcements_feed\FunctionalJavascript\AlertsJsonFeedTest
- main core/modules/announcements_feed/tests/src/FunctionalJavascript/AlertsJsonFeedTest.php \Drupal\Tests\announcements_feed\FunctionalJavascript\AlertsJsonFeedTest
- main core/modules/announcements_feed/tests/src/Functional/AlertsJsonFeedTest.php \Drupal\Tests\announcements_feed\Functional\AlertsJsonFeedTest
Test the access announcement according to json feed changes.
Attributes
#[Group('announcements_feed')]
#[RunTestsInSeparateProcesses]
Hierarchy
- class \Drupal\Tests\BrowserTestBase uses \Drupal\Tests\DrupalTestCaseTrait, \Drupal\Core\Test\FunctionalTestSetupTrait, \Drupal\Tests\UiHelperTrait, \Drupal\Core\Test\TestSetupTrait, \Drupal\Tests\block\Traits\BlockCreationTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\node\Traits\NodeCreationTrait, \Drupal\Tests\node\Traits\ContentTypeCreationTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\user\Traits\UserCreationTrait, \Drupal\Tests\XdebugRequestTrait, \Drupal\Tests\PhpUnitCompatibilityTrait, \Drupal\TestTools\Extension\DeprecationBridge\ExpectDeprecationTrait, \Drupal\Tests\ExtensionListTestTrait extends \PHPUnit\Framework\TestCase
- class \Drupal\Tests\announcements_feed\Functional\AlertsJsonFeedTest extends \Drupal\Tests\BrowserTestBase
Expanded class hierarchy of AlertsJsonFeedTest
File
-
core/
modules/ announcements_feed/ tests/ src/ Functional/ AlertsJsonFeedTest.php, line 16
Namespace
Drupal\Tests\announcements_feed\FunctionalView source
class AlertsJsonFeedTest extends BrowserTestBase {
/**
* {@inheritdoc}
*/
protected static $modules = [
'user',
'announcements_feed',
'announce_feed_test',
];
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* A user with permission to access toolbar and access announcements.
*
* @var \Drupal\user\UserInterface
*/
protected UserInterface $user;
/**
* {@inheritdoc}
*/
public function setUp() : void {
if ($this->name() === 'testAnnounceFeedUpdatedAndRemoved') {
$this->markTestSkipped('Skipped due to major version-specific logic. See https://www.drupal.org/project/drupal/issues/3359322');
}
parent::setUp();
$this->user = $this->drupalCreateUser([
'access announcements',
]);
AnnounceTestHttpClientMiddleware::setAnnounceTestEndpoint('/announce-feed-json/community-feeds');
}
/**
* Check the status of the announcements when the feed is updated and removed.
*/
public function testAnnounceFeedUpdatedAndRemoved() : void {
$this->drupalLogin($this->user);
$this->drupalGet('/admin/announcements_feed');
$page_html = $this->getSession()
->getPage()
->getHtml();
$this->assertStringNotContainsString('Only 10 - Drupal 106 is available and this feed is Updated', $page_html);
// Change the feed url and reset temp storage.
AnnounceTestHttpClientMiddleware::setAnnounceTestEndpoint('/announce-feed-json/updated');
$this->drupalGet('/admin/announcements_feed');
$page_html = $this->getSession()
->getPage()
->getHtml();
$this->assertStringContainsString('Only 10 - Drupal 106 is available and this feed is Updated', $page_html);
$this->drupalLogout();
// Change the feed url and reset temp storage.
AnnounceTestHttpClientMiddleware::setAnnounceTestEndpoint('/announce-feed-json/removed');
$this->drupalGet('/admin/announcements_feed');
$page_html = $this->getSession()
->getPage()
->getHtml();
$this->assertStringNotContainsString('Only 10 - Drupal 106 is available and this feed is Updated', $page_html);
}
/**
* Check with an empty JSON feed.
*/
public function testAnnounceFeedEmpty() : void {
// Change the feed url and reset temp storage.
AnnounceTestHttpClientMiddleware::setAnnounceTestEndpoint('/announce-feed-json/empty');
$this->drupalLogin($this->user);
$this->drupalGet('/admin/announcements_feed');
$this->assertStringContainsString('No announcements available', $this->getSession()
->getPage()
->getHtml());
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.