Skip to content
Snippets Groups Projects
Verified Commit cf174d10 authored by Dave Long's avatar Dave Long
Browse files

Issue #3422040 by mondrake: Make remaining Drupal\Tests\Core\Form data providers, static

parent 4ec07d68
No related branches found
No related tags found
No related merge requests found
......@@ -950,7 +950,7 @@ public function testSet($key, $value) {
/**
* Provides data to self::testSet().
*/
public function providerSet() {
public static function providerSet(): array {
return [
['FOO', 'BAR'],
['FOO', NULL],
......@@ -987,7 +987,7 @@ public function testGet($key, $value = NULL) {
/**
* Provides data to self::testGet().
*/
public function providerGet() {
public static function providerGet(): array {
return [
['FOO', 'BAR'],
['FOO', NULL],
......@@ -1017,7 +1017,7 @@ public function testHas($exists, $key) {
/**
* Provides data to self::testHas().
*/
public function providerHas() {
public static function providerHas(): array {
return [
[TRUE, 'FOO'],
[FALSE, 'FOO'],
......@@ -1445,13 +1445,13 @@ public function testPrepareCallback($unprepared_callback, callable $prepared_cal
/**
* Provides data to self::testPrepareCallback().
*/
public function providerPrepareCallback() {
public static function providerPrepareCallback(): array {
$function = 'sleep';
$shorthand_form_method = '::submit()';
$closure = function () {};
$static_method_string = __METHOD__;
$static_method_array = [__CLASS__, __FUNCTION__];
$object_method_array = [$this, __FUNCTION__];
$object_method_array = [new static(), __FUNCTION__];
return [
// A shorthand form method is generally expanded to become a method on an
......
......@@ -24,7 +24,7 @@ class SubformStateTest extends UnitTestCase {
*
* @var mixed[]
*/
protected $formStateValues = [
protected static $formStateValues = [
'foo' => 'bar',
'dog' => [
'breed' => 'Pit bull',
......@@ -70,7 +70,7 @@ class SubformStateTest extends UnitTestCase {
*/
public function testGetValues(array $parents, $expected) {
$parent_form_state = new FormState();
$parent_form_state->setValues($this->formStateValues);
$parent_form_state->setValues(static::$formStateValues);
$subform = NestedArray::getValue($this->parentForm, $parents);
$subform_state = SubformState::createForSubform($subform, $this->parentForm, $parent_form_state);
......@@ -86,11 +86,11 @@ public function testGetValues(array $parents, $expected) {
/**
* Provides data to self::testGetValues().
*/
public function providerGetValues() {
public static function providerGetValues(): array {
$data = [];
$data['exist'] = [
['dog'],
$this->formStateValues['dog'],
static::$formStateValues['dog'],
];
return $data;
......@@ -115,11 +115,11 @@ public function testGetValuesBroken(array $parents, $expected) {
/**
* Provides data to self::testGetValuesBroken().
*/
public function providerGetValuesBroken() {
public static function providerGetValuesBroken(): array {
$data = [];
$data['exist'] = [
['foo'],
$this->formStateValues['foo'],
static::$formStateValues['foo'],
];
$data['nested'] = [
['dog', 'name'],
......@@ -136,7 +136,7 @@ public function providerGetValuesBroken() {
*/
public function testGetValue($parents, $key, $expected, $default = NULL) {
$parent_form_state = new FormState();
$parent_form_state->setValues($this->formStateValues);
$parent_form_state->setValues(static::$formStateValues);
$subform = NestedArray::getValue($this->parentForm, $parents);
$subform_state = SubformState::createForSubform($subform, $this->parentForm, $parent_form_state);
......@@ -194,7 +194,7 @@ public static function providerTestGetValueBroken() {
*/
public function testSetValues($parents, $new_values, $expected) {
$parent_form_state = new FormState();
$parent_form_state->setValues($this->formStateValues);
$parent_form_state->setValues(static::$formStateValues);
$subform = NestedArray::getValue($this->parentForm, $parents);
$subform_state = SubformState::createForSubform($subform, $this->parentForm, $parent_form_state);
......@@ -231,14 +231,14 @@ public function testSetValuesBroken($parents, $new_values, $expected) {
/**
* Provides data to self::testSetValuesBroken().
*/
public function providerTestSetValuesBroken() {
public static function providerTestSetValuesBroken(): array {
$data = [];
$data['exist'] = [
['foo'],
[],
[
'foo' => [],
'dog' => $this->formStateValues['dog'],
'dog' => static::$formStateValues['dog'],
],
];
return $data;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment