gcode-mirror / google-highly-open-participation-drupal

Automatically exported from code.google.com/p/google-highly-open-participation-drupal
0 stars 0 forks source link

Write Simpletests for CCK #157

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Create simpletests for the D6 version of CCK to test the new CRUD (create,
read, update, delete) API. This task is to create an overall structure for unit
tests that will ensure this functionality works, and implement a few tests
to use as a starting point for further test development.

The Simpletest module provides a framework for running automated unit
tests in Drupal. Unit testing involves taking a small portion of code, a
unit, and subjecting it to programmatic tests to prove its correctness.
This can be extremely useful to help insure that new code does not
introduce bugs into existing functionality. Thus, having a full suite of
unit tests for Drupal 6.x CCK functionality using the Simpletest module
would be a major step forward for the project and would help insure that
only high-quality code is committed. 

For this task, you need to first install and familiarize yourself with the
simpletest module (use the cvs HEAD version with Drupal HEAD/6.x RC):
http://drupal.org/project/simpletest
http://drupal.org/simpletest
http://www.lullabot.com/articles/introduction-unit-testing

A very very crude start for the tests can be created from the browser with
http://drupal.org/project/simpletest_automator -- generated tests need
serious cleanup and editing.

The tests should create a user who makes various changes to the field
settings, then test that they produce the right results.

What to test in each step below:

* When checking the database structure, check two things:

** Check drupal_get_schema is the expected database schema according
to the rules above. Checking for tables and columns is probably enough,
without going as far as actual column definitions.

** Check the actual db structure matches drupal_get_schema. We can
use Schema.module's db inspection features : see
schema_compare_table() function.

* When checking a node's values, test that a node_load returns the 
expected field data.

Create simpletest code for CCK that will easily build tests, i.e. using
setUp and
tearDown functions to provide self-clearing test context , finding a 
way to have "now re-run tests 1-10 using a different node types/fields 
context".

Create two initial tests:

============================================
Test 1
Check single->multiple + sharing multiple field1
============================================

* Create three new content types : type1, type2, type3.

* Create three new nodes, one each in each content type,
node1 (type1), node2 (type2), node3 (type3)

* On content type type1, create a field, field1, a single value text field
that 
uses filtered text (this will create a 2 column field).
A table called 'content_type_type1 should be created with the following
columns: nid, vid, field_field1_value, field_field1_format.

* Fill in a value for node1, set the format to Full HTML.
Check that the node has the right values.

* change field1 to unlimited
The field_field1_value and field_field1_format columns should drop out of the 
table 'content_type_type1' and a new table should be created called 
'content_field_field1' which should have columns nid, vid, delta, 
field_field1_value, and field_field1_format, with the values that
were in the previous table.

* fill in values for node1
Check that the node has the previous values in the first available slot
and that both the value and the format are correct.

* add existing field1 to type2
A new content_type_type2 table should be created with
columns nid and vid.

* fill in values for node2, and set the format to Full HTML.
Check that the new node has the right values.

* add existing field1 to type3
A new content_type_type3 table should be created with
columns nid and vid.

*  fill in values for node3
Check that the new node has the right values.

* remove field1 from type3
The content_type_type3 table should disappear.
Node3 should now have no field1.

* remove field1 from type2
The content_field_field1 table should disappear. 
Node 2 should have no field.

* remove field1 from type1
The content_type_type1 table should disappear.
All nodes should lose their field values.

============================================
Test 2
Check multiple->single + sharing single field1
============================================

* Create three new content types : type1, type2, type3.

* Create three new nodes, one each in each content type,
node1 (type1), node2 (type2), node3 (type3)

* Create a field, field1, a multiple value text field that uses 
filtered text (to create a 2 column field) and add field1 to type1.

A table called 'content_type_type1 should be created with the following
columns: nid, vid.

A new table should be created, 'content_field_field1' with
columns nid, vid, delta, field_field1_value, and field_field1_format.

* fill in several values for node1, set the formats to Full HTML
Check that the node has the right values.

* change field1 to single
The content_field_field1 table should disappear. The 
field_field1_value and field_field1_format columns should 
be added to content_type_type1.

* fill in values for node1
Check that node1 retains the first value in the field.

* add existing field1 to type2
A new content_type_type2 table should be created with
columns nid and vid.

The content_type_type1 table should lose the field_field1_value 
and field_field1_format columns, and a new content_field_field1 
table should be created with columns nid, vid, field_field1_value, 
and field_field1_format.

* fill in a value for node2
Check that node1 did not lose its value and that node 2 has the right
value.

* add field1 to type3
A new content_type_type3 table should be created with
columns nid and vid.

* fill in a value for node3
Check that all nodes have the right values.

* remove field1 from type3
The table content_type_type3 should disappear.
Node 3 should lose the field value.

* remove field1 from type2
The table content_type_type2 should disappear.
The table content_field_field1 should disappear.
The table content_type_type1 should now have
columns nid, vid, value, format

Node 2 should lose the field value.
Node 1 should still have the right value.

* remove field1 from type1
The table content_type_type1 should disappear.
None of the nodes should have a field value.

This suite should be written as a single .test file and should achieve
RTBC status at http://drupal.org/node/211215

Resources
CCK :
- http://drupal.org/node/101723 (CCK handbook), especially
http://drupal.org/node/82661, http://drupal.org/node/133705
- Robert Douglas's intro to CCK at
http://www.lullabot.com/articles/an_introduction_to_the_content_construc...
- PHPDocs for content_field_instance_* CRUD functions in CCK's content_crud.inc

Simpletests :
- http://drupal.org/simpletest (Simpletest handbook)
- Angie Byron's and Robert Douglas's unit test explanation at
http://www.lullabot.com/articles/drupal-module-developer-guide-simpletes...

Required modules
http://drupal.org/node/96064 (CCK HEAD (for D6))
http://drupal.org/project/simpletest (Simpletest module)
http://drupal.org/project/schema (Schema module)

Original issue reported on code.google.com by elder...@gmail.com on 17 Jan 2008 at 5:14

GoogleCodeExporter commented 9 years ago

Original comment by acli...@gmail.com on 17 Jan 2008 at 5:17

GoogleCodeExporter commented 9 years ago
I claim this task.

Original comment by kou...@gmail.com on 21 Jan 2008 at 8:32

GoogleCodeExporter commented 9 years ago
ok kourge, it's yours.

Original comment by acli...@gmail.com on 21 Jan 2008 at 8:35

GoogleCodeExporter commented 9 years ago
I unclaim this task.

Original comment by kou...@gmail.com on 22 Jan 2008 at 3:55

GoogleCodeExporter commented 9 years ago

Original comment by dmitri...@gmail.com on 22 Jan 2008 at 3:57

GoogleCodeExporter commented 9 years ago
Ok, unclaimed.

Original comment by acli...@gmail.com on 22 Jan 2008 at 3:57

GoogleCodeExporter commented 9 years ago
I claim this task.

Original comment by cor...@gmail.com on 22 Jan 2008 at 7:58

GoogleCodeExporter commented 9 years ago
Re-Claimed. :)

Original comment by webchick...@gmail.com on 22 Jan 2008 at 8:00

GoogleCodeExporter commented 9 years ago
This got marked as closed, but should be claimed.

Original comment by elder...@gmail.com on 22 Jan 2008 at 11:16

GoogleCodeExporter commented 9 years ago
Thanks Karen.  I think it's pretty clear that the status should have been marked
claimed, and I believe the student submitted his "I claim this task" about 1 
minute
before the deadline, so as far as I'm concerned this *is* a valid claim (just a 
wrong
status).

Thanks for pointing this out to us.  

Original comment by acli...@gmail.com on 22 Jan 2008 at 12:09

GoogleCodeExporter commented 9 years ago
Ugh. Very sorry. Too many windows open at once. :P

Original comment by webchick...@gmail.com on 22 Jan 2008 at 2:42

GoogleCodeExporter commented 9 years ago
d.o issue pending review.

Original comment by cor...@gmail.com on 30 Jan 2008 at 10:32

GoogleCodeExporter commented 9 years ago

Original comment by acli...@gmail.com on 30 Jan 2008 at 11:07

GoogleCodeExporter commented 9 years ago
Latest version as posted to the d.o queue

Original comment by cor...@gmail.com on 2 Feb 2008 at 8:45

Attachments:

GoogleCodeExporter commented 9 years ago
Excellent job!

The code and documentation look excellent and I think you've addressed all of 
our
requests. I think you accomplished the goal of getting a framework ready to use 
that
we can continue to tweak going forward.

Thanks!

Original comment by elder...@gmail.com on 2 Feb 2008 at 8:48

GoogleCodeExporter commented 9 years ago
Great job.  Work has been uploaded.

Original comment by acli...@gmail.com on 2 Feb 2008 at 8:52

GoogleCodeExporter commented 9 years ago
The file has been committed to CCK HEAD. Excellent job !

Original comment by y.chedem...@gmail.com on 4 Feb 2008 at 2:14