I created my custom content type 'Proposal' in D7 and used field API to attach fields. In order to write unit test for it using "simpletest" (core module), do I need to setup my proposal content type in the unit test method from scratch or will the content schema be available to the unit tests?
1 Answer
If the custom content type is set up from within a module you're testing, then no you won't have to implement hooks from within the testing environment or anything. However, if your custom content type is set up through the interface on your site then yes you will need to do the same in your test. It is very important to realize that tests run in Simpletest are from the perspective of an absolutely clean environment - no users, no permissions, no custom content types, etc - so all of that needs to be implemented in code.
It's not such a big task once you get used to writing tests though. You can probably set up your custom content type in the DrupalWebTestCase::setUp()
method. A simple series of form posts (with $this->drupalPost('path/to/form', $form_values, t('Save'));
) and your custom content type will be set up in no time.