Unverified Commit 17da1274 authored by alexpott's avatar alexpott
Browse files

Issue #2863382 by Lendude, Jo Fitzgerald, dawehner, Berdir: Common: Convert...

Issue #2863382 by Lendude, Jo Fitzgerald, dawehner, Berdir: Common: Convert system functional tests to phpunit
parent 00f65542
<?php
namespace Drupal\system\Tests\Common;
namespace Drupal\simpletest\Tests;
use Drupal\simpletest\WebTestBase;
/**
* Tests SimpleTest error and exception collector.
*
* @group Common
* @group WebTestBase
*/
class SimpleTestErrorCollectorTest extends WebTestBase {
......
<?php
namespace Drupal\system\Tests\Common;
namespace Drupal\Tests\system\Functional\Common;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\simpletest\WebTestBase;
use Drupal\Tests\BrowserTestBase;
/**
* Tests the format_date() function.
*
* @group Common
*/
class FormatDateTest extends WebTestBase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = ['language'];
/**
* Arbitrary langcode for a custom language.
*/
const LANGCODE = 'xx';
protected function setUp() {
parent::setUp('language');
$this->config('system.date')
->set('timezone.user.configurable', 1)
->save();
$formats = $this->container->get('entity.manager')
->getStorage('date_format')
->loadMultiple(['long', 'medium', 'short']);
$formats['long']->setPattern('l, j. F Y - G:i')->save();
$formats['medium']->setPattern('j. F Y - G:i')->save();
$formats['short']->setPattern('Y M j - g:ia')->save();
$this->refreshVariables();
$this->settingsSet('locale_custom_strings_' . self::LANGCODE, [
'' => ['Sunday' => 'domingo'],
'Long month name' => ['March' => 'marzo'],
]);
ConfigurableLanguage::createFromLangcode(static::LANGCODE)->save();
$this->resetAll();
}
class FormatDateTest extends BrowserTestBase {
/**
* Tests admin-defined formats in format_date().
......
<?php
namespace Drupal\Tests\system\Functional\Common;
use Drupal\Component\Serialization\Json;
use Drupal\Core\EventSubscriber\MainContentViewSubscriber;
use Drupal\Tests\BrowserTestBase;
use Drupal\Tests\system\Functional\Cache\AssertPageCacheContextsAndTagsTrait;
/**
* Performs integration tests on drupal_render().
*
* @group Common
*/
class RenderWebTest extends BrowserTestBase {
use AssertPageCacheContextsAndTagsTrait;
/**
* Modules to enable.
*
* @var array
*/
public static $modules = ['common_test'];
/**
* Asserts the cache context for the wrapper format is always present.
*/
public function testWrapperFormatCacheContext() {
$this->drupalGet('common-test/type-link-active-class');
$this->assertIdentical(0, strpos($this->getRawContent(), "<!DOCTYPE html>\n<html"));
$this->assertIdentical('text/html; charset=UTF-8', $this->drupalGetHeader('Content-Type'));
$this->assertTitle('Test active link class | Drupal');
$this->assertCacheContext('url.query_args:' . MainContentViewSubscriber::WRAPPER_FORMAT);
$this->drupalGet('common-test/type-link-active-class', ['query' => [MainContentViewSubscriber::WRAPPER_FORMAT => 'json']]);
$this->assertIdentical('application/json', $this->drupalGetHeader('Content-Type'));
$json = Json::decode($this->getRawContent());
$this->assertEqual(['content', 'title'], array_keys($json));
$this->assertIdentical('Test active link class', $json['title']);
$this->assertCacheContext('url.query_args:' . MainContentViewSubscriber::WRAPPER_FORMAT);
}
}
<?php
namespace Drupal\system\Tests\Common;
namespace Drupal\Tests\system\Kernel\Common;
use Drupal\Core\Url;
use Drupal\simpletest\WebTestBase;
use Drupal\KernelTests\KernelTestBase;
/**
* Make sure that attaching feeds works correctly with various constructs.
*
* @group Common
*/
class AddFeedTest extends WebTestBase {
class AddFeedTest extends KernelTestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['system'];
/**
* Tests attaching feeds with paths, URLs, and titles.
......
<?php
namespace Drupal\system\Tests\Common;
namespace Drupal\Tests\system\Kernel\Common;
use Drupal\Component\Serialization\Json;
use Drupal\Core\EventSubscriber\MainContentViewSubscriber;
use Drupal\Core\Url;
use Drupal\simpletest\WebTestBase;
use Drupal\KernelTests\KernelTestBase;
/**
* Performs integration tests on drupal_render().
*
* @group Common
* @group system
*/
class RenderWebTest extends WebTestBase {
class FormElementsRenderTest extends KernelTestBase {
/**
* Modules to enable.
*
* @var array
* {@inheritdoc}
*/
public static $modules = ['common_test'];
/**
* Asserts the cache context for the wrapper format is always present.
*/
public function testWrapperFormatCacheContext() {
$this->drupalGet('common-test/type-link-active-class');
$this->assertIdentical(0, strpos($this->getRawContent(), "<!DOCTYPE html>\n<html"));
$this->assertIdentical('text/html; charset=UTF-8', $this->drupalGetHeader('Content-Type'));
$this->assertTitle('Test active link class | Drupal');
$this->assertCacheContext('url.query_args:' . MainContentViewSubscriber::WRAPPER_FORMAT);
$this->drupalGet('common-test/type-link-active-class', ['query' => [MainContentViewSubscriber::WRAPPER_FORMAT => 'json']]);
$this->assertIdentical('application/json', $this->drupalGetHeader('Content-Type'));
$json = Json::decode($this->getRawContent());
$this->assertEqual(['content', 'title'], array_keys($json));
$this->assertIdentical('Test active link class', $json['title']);
$this->assertCacheContext('url.query_args:' . MainContentViewSubscriber::WRAPPER_FORMAT);
}
protected static $modules = ['common_test', 'system'];
/**
* Tests rendering form elements without passing through
......@@ -152,7 +130,7 @@ public function testDrupalRenderFormElements() {
'#title' => $this->randomMachineName(),
'#markup' => $this->randomMachineName(),
];
$this->assertRenderedElement($element, '//details/div/div[contains(@class, :class) and contains(., :markup)]', [
$this->assertRenderedElement($element, '//details/div[contains(@class, :class) and contains(., :markup)]', [
':class' => 'js-form-type-item',
':markup' => $element['item']['#markup'],
]);
......@@ -162,9 +140,7 @@ public function testDrupalRenderFormElements() {
* Tests that elements are rendered properly.
*/
protected function assertRenderedElement(array $element, $xpath, array $xpath_args = []) {
$original_element = $element;
$this->setRawContent(drupal_render_root($element));
$this->verbose('<hr />' . $this->getRawContent());
$this->render($element);
// @see \Drupal\simpletest\WebTestBase::xpath()
$xpath = $this->buildXPathQuery($xpath, $xpath_args);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment