Skip to content

Commit

Permalink
by slashrsm: Convert test based on https://www.drupal.org/node/2489956.
Browse files Browse the repository at this point in the history
  • Loading branch information
slashrsm committed Sep 17, 2015
1 parent 6acb43f commit 7a6f646
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 21 deletions.
8 changes: 3 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ php:

matrix:
fast_finish: true
allow_failures:
- php: 7
- php: hhvm

branches:
only:
Expand Down Expand Up @@ -86,9 +83,10 @@ env:
matrix:
# [[[ SELECT ANY OR MORE OPTIONS ]]]
#- DRUPAL_TI_RUNNERS="phpunit"
- DRUPAL_TI_RUNNERS="simpletest"
#- DRUPAL_TI_RUNNERS="simpletest"
#- DRUPAL_TI_RUNNERS="behat"
#- DRUPAL_TI_RUNNERS="phpunit simpletest behat"
- DRUPAL_TI_RUNNERS="phpunit-core"

mysql:
database: drupal_travis_db
Expand All @@ -112,7 +110,7 @@ before_script:

script:
- drupal-ti --include .travis-phpcs.sh
- drupal-ti script
- export SIMPLETEST_DB=mysql://root:@127.0.0.1/drupal_travis_db; drupal-ti script

after_script:
- drupal-ti after_script
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

/**
* @file
* Contains \Drupal\entity_browser\Tests\EntityBrowserTest.
* Contains \Drupal\entity_browser\Kernel\Extension\EntityBrowserTest.
*/

namespace Drupal\entity_browser\Tests;
namespace Drupal\entity_browser\Kernel\Extension;

use Drupal\Component\FileCache\FileCacheFactory;
use Drupal\Component\Plugin\Exception\PluginException;
use Drupal\Core\Config\Entity\ConfigEntityStorage;
use Drupal\Core\Entity\EntityMalformedException;
Expand Down Expand Up @@ -57,6 +58,7 @@ class EntityBrowserTest extends KernelTestBase {
* {@inheritdoc}
*/
protected function setUp() {
FileCacheFactory::setPrefix($this->randomString(4));
parent::setUp();

$this->controller = $this->container->get('entity.manager')->getStorage('entity_browser');
Expand Down Expand Up @@ -220,8 +222,8 @@ protected function deleteTests() {
/**
* Tests dynamic routes.
*/
protected function testDynamicRoutes() {
$this->installConfig(array('entity_browser_test'));
public function testDynamicRoutes() {
$this->installConfig(['entity_browser_test']);
$this->installSchema('system', 'router');
$this->container->get('router.builder')->rebuild();

Expand Down Expand Up @@ -253,28 +255,28 @@ protected function testDynamicRoutes() {
/**
* Tests dynamically generated permissions.
*/
protected function testDynamicPermissions() {
$this->installConfig(array('entity_browser_test'));
public function testDynamicPermissions() {
$this->installConfig(['entity_browser_test']);
$permissions = $this->container->get('user.permissions')->getPermissions();

/** @var $entity \Drupal\entity_browser\EntityBrowserInterface */
$entity = $this->controller->load('test');

$expected_permission_name = 'access ' . $entity->id() . ' entity browser pages';
$expected_permission = array(
'title' => $this->container->get('string_translation')->translate('Access @name pages', array('@name' => $entity->label())),
'description' => $this->container->get('string_translation')->translate('Access pages that %browser uses to operate.', array('%browser' => $entity->label())),
$expected_permission = [
'title' => $this->container->get('string_translation')->translate('Access @name pages', ['@name' => $entity->label()]),
'description' => $this->container->get('string_translation')->translate('Access pages that %browser uses to operate.', ['%browser' => $entity->label()]),
'provider' => 'entity_browser',
);
];

$this->assertSame($permissions[$expected_permission_name], $expected_permission, 'Dynamically generated permission found.');
}

/**
* Tests default widget selector.
*/
protected function testDefaultWidget() {
$this->installConfig(array('entity_browser_test'));
public function testDefaultWidget() {
$this->installConfig(['entity_browser_test']);

/** @var $entity \Drupal\entity_browser\EntityBrowserInterface */
$entity = $this->controller->load('test');
Expand All @@ -296,11 +298,10 @@ protected function testDefaultWidget() {
/**
* Test selected event dispatch.
*/
protected function testSelectedEvent() {
$this->installConfig(array('entity_browser_test'));
public function testSelectedEvent() {
$this->installConfig(['entity_browser_test']);

$form_state = new FormState();
$form = [];

/** @var $entity \Drupal\entity_browser\EntityBrowserInterface */
$entity = $this->controller->load('dummy_widget');
Expand All @@ -309,7 +310,7 @@ protected function testSelectedEvent() {
/** @var \Drupal\Core\Entity\EntityFormInterface $form_object */
$form_object = $this->container->get('entity.manager')->getFormObject($entity->getEntityTypeId(), 'default');
$form_object->setEntity($entity);
$form_state = (new FormState())->setFormState(array());
$form_state = (new FormState())->setFormState([]);

\Drupal::formBuilder()->buildForm($form_object, $form_state);
\Drupal::formBuilder()->submitForm($form_object, $form_state);
Expand Down

0 comments on commit 7a6f646

Please sign in to comment.