Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once(APPPATH . '/controllers/test/Toast.php');
- class Contact_tests extends Toast
- {
- function Contact_tests()
- {
- parent::Toast(__FILE__);
- // Load any models, libraries etc. you need here
- $this->load->model('contact_model', 'contact');
- }
- /**
- * OPTIONAL; Anything in this function will be run before each test
- * Good for doing cleanup: resetting sessions, renewing objects, etc.
- */
- function _pre() {}
- /**
- * OPTIONAL; Anything in this function will be run after each test
- * I use it for setting $this->message = $this->My_model->getError();
- */
- function _post() {}
- /* TESTS BELOW */
- function test_add_contact()
- {
- $message = array(
- 'name' => 'Test Name',
- 'email' => 'Test@email.com',
- 'subject' => 'Test Subject',
- 'message' => 'Test Message',
- 'ip_address' => $this->input->ip_address(),
- 'stamp' => $stamp = date("Y-m-d H:i:s")
- );
- // Add message
- $insert_id = $this->contact->add_message($message);
- // Get saved message
- $saved_message = $this->contact->get_message(array('id' => $insert_id));
- // Remove message
- $this->contact->remove_message(array('id' => $insert_id));
- // Remove ID from retreived message
- unset($saved_message['id']);
- $this->_assert_equals($message, $saved_message);
- }
- function test_remove_contact()
- {
- $message = array(
- 'name' => 'Test Name',
- 'email' => 'Test@email.com',
- 'subject' => 'Test Subject',
- 'message' => 'Test Message',
- 'ip_address' => $this->input->ip_address(),
- 'stamp' => $stamp = date("Y-m-d H:i:s")
- );
- // Add Message
- $insert_id = $this->contact->add_message($message);
- // Remove message
- $this->contact->remove_message(array('id' => $insert_id));
- // Get message
- $saved_message = $this->contact->get_message(array('id' => $insert_id));
- $this->_assert_equals(false, $saved_message);
- }
- }
- // End of file contact_test.php */
- // Location: ./system/application/controllers/test/contact_test.php */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement