Prev | Current Page 161 | Next

Rob Allen, Nick Lo, and Steven Brown

"Zend Framework in Action"

com',
'town' => 'London',
'country' => 'UK',
'date_of_birth' => '1981-03-15',
'sex' => 'F',
'date_created' => '2007-02-14 00:00:00',
'date_updated' => '2007-02-14 00:00:00'
);
$this->db->insert('users', $row);
}
(annotation) <#1. setUp() is called before every unit test is executed.>
(annotation) <#2. Drop the table if it exists.>
(annotation) <#3. Create the table.>
(annotation) <#4. Insert some known data.>
This is very simple code that just ensures that our database is set up correctly for every test. Note that there
is a MySQL-ism in the Drop Table command which would need to be changed for other database engines. To
insert the database rows, we take advantage of the database adapter??™s insert() method which we discussed
earlier.
We are now in a position to actually write some tests to ensure that our model works as expected!
Licensed to Menshu You
Please post comments or corrections to the Author Online forum at
http://www.manning-sandbox.com/forum.jspa?forumID=329
Testing the Users table gatway
The Users class overrides the insert() and update() functions to ensure that the date_created and date_updated
fields are filled in without the rest of the code having to worry about it. The unit tests to ensure that this code
works is shown in listing 5.


Pages:
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173
Wczasy nad morzem kasyno kino azjatyckie bwin out of home advertising