Guest User

Untitled

a guest
Jun 21st, 2018
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. class TestAccountService extends UnitTestCase
  2. {
  3. /**
  4. * The request data should enter the Account_Service in a format like this:
  5. *
  6. * $data = array( "api_sites_hostname" => "ibethel.org",
  7. * "api_first_name" => "chris",
  8. * "api_middle_name" => "danger",
  9. * "api_last_name" => "gratigny",
  10. * "api_main_phone" => "504-000-0000",
  11. * "api_mobile_phone" => "504-111-1111",
  12. * "api_work_phone" => "504-222-2222",
  13. * "api_versions_sites_id" => "ibethel.org",
  14. * "api_email" => "chrisg@ibethel.org",
  15. * "api_site_id" => "5",
  16. * "api_site_user_id" => "24"
  17. * );
  18. */
  19. function setUp()
  20. {
  21. parent::setUp();
  22. ObjectLoader::load_sites();
  23. $_POST["data"]=serialize($this->request_data_correct_auth_key());
  24. }
  25.  
  26. function tearDown()
  27. {
  28. $_POST["data"]=NULL;
  29. parent::tearDown();
  30. }
  31.  
  32. /**
  33. * Verfies that the "user_endpoint" method executes as expected, unserializing
  34. * the data sent in the POST into an array, calling the RequestParser, and
  35. * returning a User.
  36. * TODO: figure out alternative to the deprecated mock calls
  37. */
  38. function test_user_endpoint()
  39. {
  40. $controller = new Account_Service_Controller();
  41. $mock_request_parser = &new MockDefault_Request_Parser($this);
  42.  
  43. $mock_request_parser->expectOnce( "parse", array(new EqualExpectation($this->request_data_correct_auth_key())));
  44. $mock_request_parser->setReturnValue( "parse", new Account_Model());
  45.  
  46. $mock_filer = &new MockDefault_Filer( $this );
  47. $mock_filer ->expectOnce( "file", array( new IsAExpectation("Account_Model")));
  48.  
  49. $controller->set_parser($mock_request_parser);
  50. $controller->set_filer($mock_filer);
  51. $controller->user_endpoint();
  52. }
Add Comment
Please, Sign In to add comment