You are here

protected function XmlSitemapTestBase::assertFlag in XML sitemap 2.x

Same name and namespace in other branches
  1. 8 tests/src/Functional/XmlSitemapTestBase.php \Drupal\Tests\xmlsitemap\Functional\XmlSitemapTestBase::assertFlag()

Assert Flag.

4 calls to XmlSitemapTestBase::assertFlag()
XmlSitemapUnitTest::testAssertFlag in tests/src/Functional/XmlSitemapUnitTest.php
Tests for xmlsitemap flags.
XmlSitemapUnitTest::testLinkDelete in tests/src/Functional/XmlSitemapUnitTest.php
Tests for XmlSitemapLinkStorage::delete().
XmlSitemapUnitTest::testSaveLink in tests/src/Functional/XmlSitemapUnitTest.php
Tests for XmlSitemapLinkStorage::save().
XmlSitemapUnitTest::testUpdateLinks in tests/src/Functional/XmlSitemapUnitTest.php
TestUpdateLinks.

File

tests/src/Functional/XmlSitemapTestBase.php, line 350

Class

XmlSitemapTestBase
Helper test class with some added functions for testing.

Namespace

Drupal\Tests\xmlsitemap\Functional

Code

protected function assertFlag($variable, $assert_value = TRUE, $reset_if_true = TRUE) {
  $value = xmlsitemap_var($variable);
  if ($reset_if_true && $value) {
    $state_variables = xmlsitemap_state_variables();
    if (isset($state_variables[$variable])) {
      $this->state
        ->set($variable, FALSE);
    }
    else {
      $this->config
        ->set($variable, FALSE)
        ->save();
    }
  }
  $this
    ->assertEquals($assert_value, $value, "{$variable} is " . ($assert_value ? 'TRUE' : 'FALSE'));
  return $value == $assert_value;
}