Issue #2787655: Fix \Drupal\Tests\Core\Form\FormTestBase to not have multiple namespaces

8.3.x
Nathaniel Catchpole 2016-08-22 17:01:56 +01:00
parent 50ab536e79
commit 37010da991
2 changed files with 42 additions and 33 deletions

View File

@ -1,6 +1,6 @@
<?php
namespace Drupal\Tests\Core\Form {
namespace Drupal\Tests\Core\Form;
use Drupal\Component\Utility\Html;
use Drupal\Core\Form\FormBuilder;
@ -147,6 +147,9 @@ abstract class FormTestBase extends UnitTestCase {
protected function setUp() {
parent::setUp();
// Add functions to the global namespace for testing.
require_once __DIR__ . '/fixtures/form_base_test.inc';
$this->moduleHandler = $this->getMock('Drupal\Core\Extension\ModuleHandlerInterface');
$this->formCache = $this->getMock('Drupal\Core\Form\FormCacheInterface');
@ -311,35 +314,3 @@ abstract class FormTestBase extends UnitTestCase {
}
}
}
namespace {
function test_form_id() {
$form['test'] = array(
'#type' => 'textfield',
'#title' => 'Test',
);
$form['options'] = array(
'#type' => 'radios',
'#options' => array(
'foo' => 'foo',
'bar' => 'bar',
),
);
$form['value'] = array(
'#type' => 'value',
'#value' => 'bananas',
);
$form['actions'] = array(
'#type' => 'actions',
);
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => 'Submit',
);
return $form;
}
}

View File

@ -0,0 +1,38 @@
<?php
/**
* @file
* Functions in the global namespace for \Drupal\Tests\Core\Form\FormTestBase.
*/
/**
* Creates a test form.
*
* @return array
* The form array
*/
function test_form_id() {
$form['test'] = array(
'#type' => 'textfield',
'#title' => 'Test',
);
$form['options'] = array(
'#type' => 'radios',
'#options' => array(
'foo' => 'foo',
'bar' => 'bar',
),
);
$form['value'] = array(
'#type' => 'value',
'#value' => 'bananas',
);
$form['actions'] = array(
'#type' => 'actions',
);
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => 'Submit',
);
return $form;
}