Commit e2aaf40d authored by alexpott's avatar alexpott

Issue #2464283 by jeqq: Restore Simpletest's batch after modules installation...

Issue #2464283 by jeqq: Restore Simpletest's batch after modules installation in WebTestBase::setUp()
parent d2c38c45
<?php
/**
* @file
* Contains \Drupal\simpletest\Tests\SimpleTestInstallBatchTest.
*/
namespace Drupal\simpletest\Tests;
use Drupal\simpletest\WebTestBase;
/**
* Tests batch operations during tests execution.
*
* This demonstrates that a batch will be successfully executed during module
* installation when running tests.
*
* @group simpletest
*/
class SimpleTestInstallBatchTest extends WebTestBase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array('simpletest', 'simpletest_test', 'entity_test');
/**
* Tests loading entities created in a batch in simpletest_test_install().
*/
public function testLoadingEntitiesCreatedInBatch() {
$entity1 = entity_load('entity_test', 1);
$this->assertNotNull($entity1, 'Successfully loaded entity 1.');
$entity2 = entity_load('entity_test', 2);
$this->assertNotNull($entity2, 'Successfully loaded entity 2.');
}
}
......@@ -928,10 +928,6 @@ protected function setUp() {
->set('js.preprocess', FALSE)
->save();
// Restore the original Simpletest batch.
$batch = &batch_get();
$batch = $this->originalBatch;
// Collect modules to install.
$class = get_class($this);
$modules = array();
......@@ -955,6 +951,10 @@ protected function setUp() {
$this->rebuildContainer();
}
// Restore the original Simpletest batch.
$batch = &batch_get();
$batch = $this->originalBatch;
// Reset/rebuild all data structures after enabling the modules, primarily
// to synchronize all data structures and caches between the test runner and
// the child site.
......
name: 'Simpletest test'
type: module
description: 'Support module for Simpletest tests.'
package: Testing
version: VERSION
core: 8.x
dependencies:
- entity_test
<?php
/**
* Implements hook_install().
*/
function simpletest_test_install() {
$total = 2;
$operations = array();
for ($i = 1; $i <= $total; $i++) {
$operations[] = array('_simpletest_test_callback', array($i));
}
$batch = array(
'operations' => $operations,
);
batch_set($batch);
$batch =& batch_get();
$batch['progressive'] = FALSE;
batch_process();
}
/**
* Callback for batch operations.
*/
function _simpletest_test_callback($id) {
$entity = entity_create('entity_test', array('id' => $id));
$entity->save();
}
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