Patch imitates the way node_type_form_submit() saves the vars.

Use case is in OG7 tests:

    // Create post content type.
    $group_post = $this->drupalCreateContentType(array(), array('og_group_post_type' => 'group post'));

    $this->assertTrue(og_is_group_post_type($group_post->type), t('Content type is group post.'));

Comments

amitaibu’s picture

Priority: Normal » Minor

On the other hand I can use drupalPost(), but thougt it might be a nice addition. Not sure, anyway, I'll set it to minor.

jhodgdon’s picture

Status: Needs review » Needs work

This seems like a reasonable addition to the testing framework, but you need slightly better documentation -- the variable that is being saved is key_typename, and this is not documented in your proposed documentation header for the $vars parameter.

amitaibu’s picture

Status: Needs work » Needs review
StatusFileSize
new1.44 KB

Thanks jhodgdon, I've added:
"The variables are saved in the form of [variable]_[content type name]."

jhodgdon’s picture

Status: Needs review » Needs work

How about instead of using "bar" for the variable value, you use "value"? I think it is clearer. Also, we normally just continue the doc on the same line, rather than having a return in the middle of something like this:

+   * @param $vars
+   *   An array with variables that need to be saved, before the content type is
+   *   created. Example: 'var' => 'bar'.
+   *   The variables are saved in the form of [variable]_[content type name].
jhodgdon’s picture

One other thing. I think you will need to add a test to your patch for this behavior -- test whether this new addition works within the testing framework.

amitaibu’s picture

Status: Needs work » Needs review
StatusFileSize
new2.5 KB

Patch includes simpleTest.

Status: Needs review » Needs work

The last submitted patch failed testing.

jhodgdon’s picture

Status: Needs work » Needs review

One minor thing in a doc header; other than that, I like the patch in #6:

+   * @param $vars
+   *   An array with variables that need to be saved, before the content type is
+   *   created (e.g. array('var' => 'value')). The variables are saved in the
+   *   form of [variable]_[content type name].

How about making 'var' agree with [variable] here? So change this to:

+   * @param $vars
+   *   An array with variables that need to be saved, before the content type is
+   *   created (e.g. array('variable' => 'value')). The variables are saved in the
+   *   form of [variable]_[content type name].
jhodgdon’s picture

Whoops, the test bot came through while I was posting that... looks like maybe the test bot is having trouble, so I have requested a retest.

amitaibu’s picture

StatusFileSize
new2.53 KB

Ok, I've also changed also the function signature to be "variables".

Status: Needs review » Needs work

The last submitted patch failed testing.

jhodgdon’s picture

OK, I like your patch now. Apparently the Drupal 7 testing engine is not so happy with it, either that or the Drupal 7 testing engine is having trouble itself...

amitaibu’s picture

Status: Needs work » Needs review
StatusFileSize
new2.41 KB

Better function names for the testing. Lets see if testbot likes this one better.

amitaibu’s picture

@jhodgdon,
Testbot seems to be ok with latest patch :)

jhodgdon’s picture

OK, I am happy with the patch -- I think it is clearly written and the documentation headers are good.

I will leave it to someone else to figure out whether this feature should be added to the SimpleTest module.

MichaelCole’s picture

thedavidmeister’s picture

Status: Needs review » Needs work

Patch did not apply.

+   * @param $vars
+   *   An array with variables that need to be saved, before the content type is
+   *   created (e.g. array('var' => 'value')). The variables are saved in the
+   *   form of [variable]_[content type name].
    * @return
    *   Created content type.

Add a space between @param and @return.

+/**
+ * Test simpletest functions.
+ */
+class SimpleTestAssertUnitTest extends DrupalWebTestCase {
+  public static function getInfo() {
+    return array(
+      'name' => 'SimpleTest unit tests',
+      'description' => 'Test the simpletest unit testing functions.',
+      'group' => 'SimpleTest',
+    );
+  }
+
+  /**
+   * Test creating a new content type and saving the content type variables.
+   */
+  function testDrupalCreateContentType() {
+    $content_type = $this->drupalCreateContentType(array(), array('var' => 'value'));
+    $this->assertTrue(variable_get('var_' . $content_type->type, '') == 'value', t('Variable was saved when creating the new content type.'));
+  }
+}

This test looks like it could be better named and documented than simple "SimpleTestAssertUnitTest". Have a look at other tests in that file for examples.

I'm trialling something a bit different at #2094585: [policy, no patch] Core review bonus, I'd like to use this review for a bonus at #1987396: Refactor & Clean-up comment.module theme functions.

thedavidmeister’s picture

Version: 7.x-dev » 8.x-dev

oh, additionally, new features should be filed against latest version of core and back-ported after commit.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

dawehner’s picture

Issue summary: View changes
Status: Needs work » Fixed

This got fixed in the meantime, mostly by moving to config entity types..

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.