/** * @param $mock * @return $this */ public function verify($mock) { if (!$this->scope) { $extractMock = Mock::extractMock($mock); $this->scope = $extractMock->_called_methods; } return $this; }
/** * @test */ public function shouldThrowExceptionOnExecutionError() { //given Mock::when($this->pdoMock)->errorInfo()->thenReturn(array('HY000', '20102', 'Execution error')); $executor = new PDOPreparedStatementExecutor(); //when CatchException::when($executor)->createPDOStatement($this->dbMock, 'sql', array(), 'sql string'); //then CatchException::assertThat()->isInstanceOf('\\Ouzo\\DbException'); }
/** * @test */ public function shouldCreateTicketModels() { //given $curl = Mock::create('\\Cerb\\CurlCaller'); Mock::when($curl)->call(Mock::anyArgList())->thenReturn(json_decode('{"__build":2015090201,"__status":"success","__version":"7.0.5","count":1,"page":1,"results":[{"_context":"cerberusweb.contexts.ticket","_label":"[#ACB-99934-772] second","closed_at":0,"created":1453283445,"elapsed_response_first":"0","elapsed_resolution_first":"0","id":2,"importance":50,"mask":"ACB-99934-772","num_messages":"1","org_id":0,"reopen_date":0,"spam_score":0.0001,"spam_training":"N","subject":"second","updated":1453283445,"status":"waiting","url":"http:\\/\\/localhost:8080\\/cerb-7.0.5\\/profiles\\/ticket\\/ACB-99934-772","group_id":1,"bucket_id":1,"initial_message_id":2,"initial_response_message_id":0,"latest_message_id":2,"owner_id":0,"group__context":"cerberusweb.contexts.group","bucket__context":"cerberusweb.contexts.bucket","initial_message__context":"cerberusweb.contexts.message","initial_message_sender__context":"cerberusweb.contexts.address","initial_message_sender_org__context":"cerberusweb.contexts.org","initial_message_worker__context":"cerberusweb.contexts.worker","initial_message_worker_address__context":"cerberusweb.contexts.address","initial_message_worker_address_org__context":"cerberusweb.contexts.org","initial_message_worker_calendar__context":"cerberusweb.contexts.calendar","initial_response_message__context":"cerberusweb.contexts.message","initial_response_message_sender__context":"cerberusweb.contexts.address","initial_response_message_sender_org__context":"cerberusweb.contexts.org","initial_response_message_worker__context":"cerberusweb.contexts.worker","initial_response_message_worker_address__context":"cerberusweb.contexts.address","initial_response_message_worker_address_org__context":"cerberusweb.contexts.org","initial_response_message_worker_calendar__context":"cerberusweb.contexts.calendar","latest_message__context":"cerberusweb.contexts.message","latest_message_sender__context":"cerberusweb.contexts.address","latest_message_sender_org__context":"cerberusweb.contexts.org","latest_message_worker__context":"cerberusweb.contexts.worker","latest_message_worker_address__context":"cerberusweb.contexts.address","latest_message_worker_address_org__context":"cerberusweb.contexts.org","latest_message_worker_calendar__context":"cerberusweb.contexts.calendar","owner__context":"cerberusweb.contexts.worker","owner_address__context":"cerberusweb.contexts.address","owner_calendar__context":"cerberusweb.contexts.calendar","org__context":"cerberusweb.contexts.org"}],"results_meta":{"labels":{"_label":"Ticket","num_messages":"Ticket # messages","bucket__label":"Ticket bucket","bucket_is_default":"Ticket bucket default","bucket_id":"Ticket bucket id","bucket_name":"Ticket bucket name","bucket_record_url":"Ticket bucket record url","bucket_updated_at":"Ticket bucket updated","created":"Ticket created","elapsed_resolution_first":"Ticket first resolution","elapsed_response_first":"Ticket first response","group__label":"Ticket group","group_created":"Ticket group created","group_is_default":"Ticket group default","group_id":"Ticket group id","group_name":"Ticket group name","group_is_private":"Ticket group private","group_record_url":"Ticket group record url","group_updated":"Ticket group updated","id":"Ticket id","custom_1":"Ticket identifier","importance":"Ticket importance","initial_message__label":"Ticket initial message","initial_message_content":"Ticket initial message content","initial_message_created":"Ticket initial message created","initial_message_headers":"Ticket initial message headers","initial_message_html_attachment_id":"Ticket initial message html attachment id","initial_message_id":"Ticket initial message id","initial_message_is_broadcast":"Ticket initial message is broadcast","initial_message_is_not_sent":"Ticket initial message is not sent","initial_message_is_outgoing":"Ticket initial message is outgoing","initial_message_record_url":"Ticket initial message record url","initial_message_response_time":"Ticket initial message response time","initial_message_sender__label":"Ticket initial message sender","initial_message_sender_num_nonspam":"Ticket initial message sender # nonspam","initial_message_sender_num_spam":"Ticket initial message sender # spam","initial_message_sender_address":"Ticket initial message sender address","initial_message_sender_first_name":"Ticket initial message sender first name","initial_message_sender_full_name":"Ticket initial message sender full name","initial_message_sender_id":"Ticket initial message sender id","initial_message_sender_is_banned":"Ticket initial message sender is banned","initial_message_sender_is_contact":"Ticket initial message sender is contact","initial_message_sender_is_defunct":"Ticket initial message sender is defunct","initial_message_sender_last_name":"Ticket initial message sender last name","initial_message_sender_org__label":"Ticket initial message sender org","initial_message_sender_org_city":"Ticket initial message sender org city","initial_message_sender_org_country":"Ticket initial message sender org country","initial_message_sender_org_created":"Ticket initial message sender org created","initial_message_sender_org_id":"Ticket initial message sender org id","initial_message_sender_org_name":"Ticket initial message sender org name","initial_message_sender_org_phone":"Ticket initial message sender org phone","initial_message_sender_org_postal":"Ticket initial message sender org postal","initial_message_sender_org_record_url":"Ticket initial message sender org record url","initial_message_sender_org_province":"Ticket initial message sender org state\\/prov","initial_message_sender_org_street":"Ticket initial message sender org street","initial_message_sender_org_updated":"Ticket initial message sender org updated","initial_message_sender_org_website":"Ticket initial message sender org website","initial_message_sender_record_url":"Ticket initial message sender record url","initial_message_sender_updated":"Ticket initial message sender updated","initial_message_worker__label":"Ticket initial message sender worker","initial_message_worker_is_superuser":"******","initial_message_worker_calendar__label":"Ticket initial message sender worker calendar","initial_message_worker_calendar_id":"Ticket initial message sender worker calendar id","initial_message_worker_calendar_name":"Ticket initial message sender worker calendar name","initial_message_worker_calendar_owner__label":"Ticket initial message sender worker calendar owner","initial_message_worker_calendar_record_url":"Ticket initial message sender worker calendar record url","initial_message_worker_calendar_updated_at":"Ticket initial message sender worker calendar updated","initial_message_worker_is_disabled":"Ticket initial message sender worker disabled","initial_message_worker_address__label":"Ticket initial message sender worker email","initial_message_worker_address_num_nonspam":"Ticket initial message sender worker email # nonspam","initial_message_worker_address_num_spam":"Ticket initial message sender worker email # spam","initial_message_worker_address_address":"Ticket initial message sender worker email address","initial_message_worker_address_first_name":"Ticket initial message sender worker email first name","initial_message_worker_address_full_name":"Ticket initial message sender worker email full name","initial_message_worker_address_id":"Ticket initial message sender worker email id","initial_message_worker_address_is_banned":"Ticket initial message sender worker email is banned","initial_message_worker_address_is_contact":"Ticket initial message sender worker email is contact","initial_message_worker_address_is_defunct":"Ticket initial message sender worker email is defunct","initial_message_worker_address_last_name":"Ticket initial message sender worker email last name","initial_message_worker_address_org__label":"Ticket initial message sender worker email org","initial_message_worker_address_org_city":"Ticket initial message sender worker email org city","initial_message_worker_address_org_country":"Ticket initial message sender worker email org country","initial_message_worker_address_org_created":"Ticket initial message sender worker email org created","initial_message_worker_address_org_id":"Ticket initial message sender worker email org id","initial_message_worker_address_org_name":"Ticket initial message sender worker email org name","initial_message_worker_address_org_phone":"Ticket initial message sender worker email org phone","initial_message_worker_address_org_postal":"Ticket initial message sender worker email org postal","initial_message_worker_address_org_record_url":"Ticket initial message sender worker email org record url","initial_message_worker_address_org_province":"Ticket initial message sender worker email org state\\/prov","initial_message_worker_address_org_street":"Ticket initial message sender worker email org street","initial_message_worker_address_org_updated":"Ticket initial message sender worker email org updated","initial_message_worker_address_org_website":"Ticket initial message sender worker email org website","initial_message_worker_address_record_url":"Ticket initial message sender worker email record url","initial_message_worker_address_updated":"Ticket initial message sender worker email updated","initial_message_worker_first_name":"Ticket initial message sender worker first name","initial_message_worker_full_name":"Ticket initial message sender worker full name","initial_message_worker_id":"Ticket initial message sender worker id","initial_message_worker_language":"Ticket initial message sender worker language","initial_message_worker_last_activity_date":"Ticket initial message sender worker last activity date","initial_message_worker_last_name":"Ticket initial message sender worker last name","initial_message_worker_record_url":"Ticket initial message sender worker record url","initial_message_worker_time_format":"Ticket initial message sender worker time format","initial_message_worker_timezone":"Ticket initial message sender worker timezone","initial_message_worker_title":"Ticket initial message sender worker title","initial_message_worker_updated":"Ticket initial message sender worker updated","initial_message_storage_size":"Ticket initial message size","initial_response_message__label":"Ticket initial response message","initial_response_message_content":"Ticket initial response message content","initial_response_message_created":"Ticket initial response message created","initial_response_message_headers":"Ticket initial response message headers","initial_response_message_html_attachment_id":"Ticket initial response message html attachment id","initial_response_message_id":"Ticket initial response message id","initial_response_message_is_broadcast":"Ticket initial response message is broadcast","initial_response_message_is_not_sent":"Ticket initial response message is not sent","initial_response_message_is_outgoing":"Ticket initial response message is outgoing","initial_response_message_record_url":"Ticket initial response message record url","initial_response_message_response_time":"Ticket initial response message response time","initial_response_message_sender__label":"Ticket initial response message sender","initial_response_message_sender_num_nonspam":"Ticket initial response message sender # nonspam","initial_response_message_sender_num_spam":"Ticket initial response message sender # spam","initial_response_message_sender_address":"Ticket initial response message sender address","initial_response_message_sender_first_name":"Ticket initial response message sender first name","initial_response_message_sender_full_name":"Ticket initial response message sender full name","initial_response_message_sender_id":"Ticket initial response message sender id","initial_response_message_sender_is_banned":"Ticket initial response message sender is banned","initial_response_message_sender_is_contact":"Ticket initial response message sender is contact","initial_response_message_sender_is_defunct":"Ticket initial response message sender is defunct","initial_response_message_sender_last_name":"Ticket initial response message sender last name","initial_response_message_sender_org__label":"Ticket initial response message sender org","initial_response_message_sender_org_city":"Ticket initial response message sender org city","initial_response_message_sender_org_country":"Ticket initial response message sender org country","initial_response_message_sender_org_created":"Ticket initial response message sender org created","initial_response_message_sender_org_id":"Ticket initial response message sender org id","initial_response_message_sender_org_name":"Ticket initial response message sender org name","initial_response_message_sender_org_phone":"Ticket initial response message sender org phone","initial_response_message_sender_org_postal":"Ticket initial response message sender org postal","initial_response_message_sender_org_record_url":"Ticket initial response message sender org record url","initial_response_message_sender_org_province":"Ticket initial response message sender org state\\/prov","initial_response_message_sender_org_street":"Ticket initial response message sender org street","initial_response_message_sender_org_updated":"Ticket initial response message sender org updated","initial_response_message_sender_org_website":"Ticket initial response message sender org website","initial_response_message_sender_record_url":"Ticket initial response message sender record url","initial_response_message_sender_updated":"Ticket initial response message sender updated","initial_response_message_worker__label":"Ticket initial response message sender worker","initial_response_message_worker_is_superuser":"******","initial_response_message_worker_calendar__label":"Ticket initial response message sender worker calendar","initial_response_message_worker_calendar_id":"Ticket initial response message sender worker calendar id","initial_response_message_worker_calendar_name":"Ticket initial response message sender worker calendar name","initial_response_message_worker_calendar_owner__label":"Ticket initial response message sender worker calendar owner","initial_response_message_worker_calendar_record_url":"Ticket initial response message sender worker calendar record url","initial_response_message_worker_calendar_updated_at":"Ticket initial response message sender worker calendar updated","initial_response_message_worker_is_disabled":"Ticket initial response message sender worker disabled","initial_response_message_worker_address__label":"Ticket initial response message sender worker email","initial_response_message_worker_address_num_nonspam":"Ticket initial response message sender worker email # nonspam","initial_response_message_worker_address_num_spam":"Ticket initial response message sender worker email # spam","initial_response_message_worker_address_address":"Ticket initial response message sender worker email address","initial_response_message_worker_address_first_name":"Ticket initial response message sender worker email first name","initial_response_message_worker_address_full_name":"Ticket initial response message sender worker email full name","initial_response_message_worker_address_id":"Ticket initial response message sender worker email id","initial_response_message_worker_address_is_banned":"Ticket initial response message sender worker email is banned","initial_response_message_worker_address_is_contact":"Ticket initial response message sender worker email is contact","initial_response_message_worker_address_is_defunct":"Ticket initial response message sender worker email is defunct","initial_response_message_worker_address_last_name":"Ticket initial response message sender worker email last name","initial_response_message_worker_address_org__label":"Ticket initial response message sender worker email org","initial_response_message_worker_address_org_city":"Ticket initial response message sender worker email org city","initial_response_message_worker_address_org_country":"Ticket initial response message sender worker email org country","initial_response_message_worker_address_org_created":"Ticket initial response message sender worker email org created","initial_response_message_worker_address_org_id":"Ticket initial response message sender worker email org id","initial_response_message_worker_address_org_name":"Ticket initial response message sender worker email org name","initial_response_message_worker_address_org_phone":"Ticket initial response message sender worker email org phone","initial_response_message_worker_address_org_postal":"Ticket initial response message sender worker email org postal","initial_response_message_worker_address_org_record_url":"Ticket initial response message sender worker email org record url","initial_response_message_worker_address_org_province":"Ticket initial response message sender worker email org state\\/prov","initial_response_message_worker_address_org_street":"Ticket initial response message sender worker email org street","initial_response_message_worker_address_org_updated":"Ticket initial response message sender worker email org updated","initial_response_message_worker_address_org_website":"Ticket initial response message sender worker email org website","initial_response_message_worker_address_record_url":"Ticket initial response message sender worker email record url","initial_response_message_worker_address_updated":"Ticket initial response message sender worker email updated","initial_response_message_worker_first_name":"Ticket initial response message sender worker first name","initial_response_message_worker_full_name":"Ticket initial response message sender worker full name","initial_response_message_worker_id":"Ticket initial response message sender worker id","initial_response_message_worker_language":"Ticket initial response message sender worker language","initial_response_message_worker_last_activity_date":"Ticket initial response message sender worker last activity date","initial_response_message_worker_last_name":"Ticket initial response message sender worker last name","initial_response_message_worker_record_url":"Ticket initial response message sender worker record url","initial_response_message_worker_time_format":"Ticket initial response message sender worker time format","initial_response_message_worker_timezone":"Ticket initial response message sender worker timezone","initial_response_message_worker_title":"Ticket initial response message sender worker title","initial_response_message_worker_updated":"Ticket initial response message sender worker updated","initial_response_message_storage_size":"Ticket initial response message size","latest_message__label":"Ticket latest message","latest_message_content":"Ticket latest message content","latest_message_created":"Ticket latest message created","latest_message_headers":"Ticket latest message headers","latest_message_html_attachment_id":"Ticket latest message html attachment id","latest_message_id":"Ticket latest message id","latest_message_is_broadcast":"Ticket latest message is broadcast","latest_message_is_not_sent":"Ticket latest message is not sent","latest_message_is_outgoing":"Ticket latest message is outgoing","latest_message_record_url":"Ticket latest message record url","latest_message_response_time":"Ticket latest message response time","latest_message_sender__label":"Ticket latest message sender","latest_message_sender_num_nonspam":"Ticket latest message sender # nonspam","latest_message_sender_num_spam":"Ticket latest message sender # spam","latest_message_sender_address":"Ticket latest message sender address","latest_message_sender_first_name":"Ticket latest message sender first name","latest_message_sender_full_name":"Ticket latest message sender full name","latest_message_sender_id":"Ticket latest message sender id","latest_message_sender_is_banned":"Ticket latest message sender is banned","latest_message_sender_is_contact":"Ticket latest message sender is contact","latest_message_sender_is_defunct":"Ticket latest message sender is defunct","latest_message_sender_last_name":"Ticket latest message sender last name","latest_message_sender_org__label":"Ticket latest message sender org","latest_message_sender_org_city":"Ticket latest message sender org city","latest_message_sender_org_country":"Ticket latest message sender org country","latest_message_sender_org_created":"Ticket latest message sender org created","latest_message_sender_org_id":"Ticket latest message sender org id","latest_message_sender_org_name":"Ticket latest message sender org name","latest_message_sender_org_phone":"Ticket latest message sender org phone","latest_message_sender_org_postal":"Ticket latest message sender org postal","latest_message_sender_org_record_url":"Ticket latest message sender org record url","latest_message_sender_org_province":"Ticket latest message sender org state\\/prov","latest_message_sender_org_street":"Ticket latest message sender org street","latest_message_sender_org_updated":"Ticket latest message sender org updated","latest_message_sender_org_website":"Ticket latest message sender org website","latest_message_sender_record_url":"Ticket latest message sender record url","latest_message_sender_updated":"Ticket latest message sender updated","latest_message_worker__label":"Ticket latest message sender worker","latest_message_worker_is_superuser":"******","latest_message_worker_calendar__label":"Ticket latest message sender worker calendar","latest_message_worker_calendar_id":"Ticket latest message sender worker calendar id","latest_message_worker_calendar_name":"Ticket latest message sender worker calendar name","latest_message_worker_calendar_owner__label":"Ticket latest message sender worker calendar owner","latest_message_worker_calendar_record_url":"Ticket latest message sender worker calendar record url","latest_message_worker_calendar_updated_at":"Ticket latest message sender worker calendar updated","latest_message_worker_is_disabled":"Ticket latest message sender worker disabled","latest_message_worker_address__label":"Ticket latest message sender worker email","latest_message_worker_address_num_nonspam":"Ticket latest message sender worker email # nonspam","latest_message_worker_address_num_spam":"Ticket latest message sender worker email # spam","latest_message_worker_address_address":"Ticket latest message sender worker email address","latest_message_worker_address_first_name":"Ticket latest message sender worker email first name","latest_message_worker_address_full_name":"Ticket latest message sender worker email full name","latest_message_worker_address_id":"Ticket latest message sender worker email id","latest_message_worker_address_is_banned":"Ticket latest message sender worker email is banned","latest_message_worker_address_is_contact":"Ticket latest message sender worker email is contact","latest_message_worker_address_is_defunct":"Ticket latest message sender worker email is defunct","latest_message_worker_address_last_name":"Ticket latest message sender worker email last name","latest_message_worker_address_org__label":"Ticket latest message sender worker email org","latest_message_worker_address_org_city":"Ticket latest message sender worker email org city","latest_message_worker_address_org_country":"Ticket latest message sender worker email org country","latest_message_worker_address_org_created":"Ticket latest message sender worker email org created","latest_message_worker_address_org_id":"Ticket latest message sender worker email org id","latest_message_worker_address_org_name":"Ticket latest message sender worker email org name","latest_message_worker_address_org_phone":"Ticket latest message sender worker email org phone","latest_message_worker_address_org_postal":"Ticket latest message sender worker email org postal","latest_message_worker_address_org_record_url":"Ticket latest message sender worker email org record url","latest_message_worker_address_org_province":"Ticket latest message sender worker email org state\\/prov","latest_message_worker_address_org_street":"Ticket latest message sender worker email org street","latest_message_worker_address_org_updated":"Ticket latest message sender worker email org updated","latest_message_worker_address_org_website":"Ticket latest message sender worker email org website","latest_message_worker_address_record_url":"Ticket latest message sender worker email record url","latest_message_worker_address_updated":"Ticket latest message sender worker email updated","latest_message_worker_first_name":"Ticket latest message sender worker first name","latest_message_worker_full_name":"Ticket latest message sender worker full name","latest_message_worker_id":"Ticket latest message sender worker id","latest_message_worker_language":"Ticket latest message sender worker language","latest_message_worker_last_activity_date":"Ticket latest message sender worker last activity date","latest_message_worker_last_name":"Ticket latest message sender worker last name","latest_message_worker_record_url":"Ticket latest message sender worker record url","latest_message_worker_time_format":"Ticket latest message sender worker time format","latest_message_worker_timezone":"Ticket latest message sender worker timezone","latest_message_worker_title":"Ticket latest message sender worker title","latest_message_worker_updated":"Ticket latest message sender worker updated","latest_message_storage_size":"Ticket latest message size","mask":"Ticket mask","org__label":"Ticket org","org_city":"Ticket org city","org_country":"Ticket org country","org_created":"Ticket org created","org_id":"Ticket org id","org_name":"Ticket org name","org_phone":"Ticket org phone","org_postal":"Ticket org postal","org_record_url":"Ticket org record url","org_province":"Ticket org state\\/prov","org_street":"Ticket org street","org_updated":"Ticket org updated","org_website":"Ticket org website","owner__label":"Ticket owner","owner_is_superuser":"******","owner_calendar__label":"Ticket owner calendar","owner_calendar_id":"Ticket owner calendar id","owner_calendar_name":"Ticket owner calendar name","owner_calendar_owner__label":"Ticket owner calendar owner","owner_calendar_record_url":"Ticket owner calendar record url","owner_calendar_updated_at":"Ticket owner calendar updated","owner_is_disabled":"Ticket owner disabled","owner_address__label":"Ticket owner email","owner_address_num_nonspam":"Ticket owner email # nonspam","owner_address_num_spam":"Ticket owner email # spam","owner_address_address":"Ticket owner email address","owner_address_id":"Ticket owner email id","owner_address_is_banned":"Ticket owner email is banned","owner_address_is_contact":"Ticket owner email is contact","owner_address_is_defunct":"Ticket owner email is defunct","owner_address_record_url":"Ticket owner email record url","owner_address_updated":"Ticket owner email updated","owner_first_name":"Ticket owner first name","owner_full_name":"Ticket owner full name","owner_id":"Ticket owner id","owner_language":"Ticket owner language","owner_last_activity_date":"Ticket owner last activity date","owner_last_name":"Ticket owner last name","owner_record_url":"Ticket owner record url","owner_time_format":"Ticket owner time format","owner_timezone":"Ticket owner timezone","owner_title":"Ticket owner title","owner_updated":"Ticket owner updated","reopen_date":"Ticket reopen at","spam_score":"Ticket spam score","spam_training":"Ticket spam training","status":"Ticket status","subject":"Ticket subject","updated":"Ticket updated","url":"Ticket url"},"types":{"_label":"context_url","created":"E","elapsed_response_first":"time_secs","elapsed_resolution_first":"time_secs","id":"id","importance":"N","mask":"S","num_messages":"N","reopen_date":"E","spam_score":"percent","spam_training":null,"status":"","subject":"S","updated":"E","url":"U","custom_1":"S","group__label":"context_url","group_created":"E","group_id":"N","group_is_default":"C","group_is_private":"C","group_name":"S","group_updated":"E","group_record_url":"U","group_reply_address_id":"N","bucket__label":"context_url","bucket_id":"N","bucket_is_default":"C","bucket_name":"S","bucket_updated_at":"E","bucket_record_url":"U","initial_message__label":"context_url","initial_message_html_attachment_id":"N","initial_message_id":"N","initial_message_content":"T","initial_message_created":"E","initial_message_is_broadcast":"C","initial_message_is_not_sent":"C","initial_message_is_outgoing":"C","initial_message_response_time":"time_secs","initial_message_storage_size":"size_bytes","initial_message_record_url":"U","initial_message_headers":null,"initial_message_sender__label":"context_url","initial_message_sender_id":"N","initial_message_sender_address":"S","initial_message_sender_first_name":"S","initial_message_sender_full_name":"S","initial_message_sender_last_name":"S","initial_message_sender_num_spam":"N","initial_message_sender_num_nonspam":"N","initial_message_sender_is_banned":"C","initial_message_sender_is_contact":"C","initial_message_sender_is_defunct":"C","initial_message_sender_updated":"E","initial_message_sender_record_url":"U","initial_message_sender_org__label":"context_url","initial_message_sender_org_id":"N","initial_message_sender_org_name":"S","initial_message_sender_org_city":"S","initial_message_sender_org_country":"S","initial_message_sender_org_created":"E","initial_message_sender_org_phone":"phone","initial_message_sender_org_postal":"S","initial_message_sender_org_province":"S","initial_message_sender_org_street":"S","initial_message_sender_org_updated":"E","initial_message_sender_org_website":"U","initial_message_sender_org_record_url":"U","initial_message_worker__label":"context_url","initial_message_worker_first_name":"S","initial_message_worker_full_name":"S","initial_message_worker_id":"N","initial_message_worker_is_disabled":"C","initial_message_worker_is_superuser":"******","initial_message_worker_language":"S","initial_message_worker_last_name":"S","initial_message_worker_last_activity_date":"E","initial_message_worker_time_format":"S","initial_message_worker_timezone":"S","initial_message_worker_title":"S","initial_message_worker_updated":"E","initial_message_worker_record_url":"U","initial_message_worker_address__label":"context_url","initial_message_worker_address_id":"N","initial_message_worker_address_address":"S","initial_message_worker_address_first_name":"S","initial_message_worker_address_full_name":"S","initial_message_worker_address_last_name":"S","initial_message_worker_address_num_spam":"N","initial_message_worker_address_num_nonspam":"N","initial_message_worker_address_is_banned":"C","initial_message_worker_address_is_contact":"C","initial_message_worker_address_is_defunct":"C","initial_message_worker_address_updated":"E","initial_message_worker_address_record_url":"U","initial_message_worker_address_org__label":"context_url","initial_message_worker_address_org_id":"N","initial_message_worker_address_org_name":"S","initial_message_worker_address_org_city":"S","initial_message_worker_address_org_country":"S","initial_message_worker_address_org_created":"E","initial_message_worker_address_org_phone":"phone","initial_message_worker_address_org_postal":"S","initial_message_worker_address_org_province":"S","initial_message_worker_address_org_street":"S","initial_message_worker_address_org_updated":"E","initial_message_worker_address_org_website":"U","initial_message_worker_address_org_record_url":"U","initial_message_worker_calendar__label":"context_url","initial_message_worker_calendar_id":"N","initial_message_worker_calendar_name":"S","initial_message_worker_calendar_owner__label":"context_url","initial_message_worker_calendar_updated_at":"E","initial_message_worker_calendar_record_url":"U","initial_response_message__label":"context_url","initial_response_message_html_attachment_id":"N","initial_response_message_id":"N","initial_response_message_content":"T","initial_response_message_created":"E","initial_response_message_is_broadcast":"C","initial_response_message_is_not_sent":"C","initial_response_message_is_outgoing":"C","initial_response_message_response_time":"time_secs","initial_response_message_storage_size":"size_bytes","initial_response_message_record_url":"U","initial_response_message_headers":null,"initial_response_message_sender__label":"context_url","initial_response_message_sender_id":"N","initial_response_message_sender_address":"S","initial_response_message_sender_first_name":"S","initial_response_message_sender_full_name":"S","initial_response_message_sender_last_name":"S","initial_response_message_sender_num_spam":"N","initial_response_message_sender_num_nonspam":"N","initial_response_message_sender_is_banned":"C","initial_response_message_sender_is_contact":"C","initial_response_message_sender_is_defunct":"C","initial_response_message_sender_updated":"E","initial_response_message_sender_record_url":"U","initial_response_message_sender_org__label":"context_url","initial_response_message_sender_org_id":"N","initial_response_message_sender_org_name":"S","initial_response_message_sender_org_city":"S","initial_response_message_sender_org_country":"S","initial_response_message_sender_org_created":"E","initial_response_message_sender_org_phone":"phone","initial_response_message_sender_org_postal":"S","initial_response_message_sender_org_province":"S","initial_response_message_sender_org_street":"S","initial_response_message_sender_org_updated":"E","initial_response_message_sender_org_website":"U","initial_response_message_sender_org_record_url":"U","initial_response_message_worker__label":"context_url","initial_response_message_worker_first_name":"S","initial_response_message_worker_full_name":"S","initial_response_message_worker_id":"N","initial_response_message_worker_is_disabled":"C","initial_response_message_worker_is_superuser":"******","initial_response_message_worker_language":"S","initial_response_message_worker_last_name":"S","initial_response_message_worker_last_activity_date":"E","initial_response_message_worker_time_format":"S","initial_response_message_worker_timezone":"S","initial_response_message_worker_title":"S","initial_response_message_worker_updated":"E","initial_response_message_worker_record_url":"U","initial_response_message_worker_address__label":"context_url","initial_response_message_worker_address_id":"N","initial_response_message_worker_address_address":"S","initial_response_message_worker_address_first_name":"S","initial_response_message_worker_address_full_name":"S","initial_response_message_worker_address_last_name":"S","initial_response_message_worker_address_num_spam":"N","initial_response_message_worker_address_num_nonspam":"N","initial_response_message_worker_address_is_banned":"C","initial_response_message_worker_address_is_contact":"C","initial_response_message_worker_address_is_defunct":"C","initial_response_message_worker_address_updated":"E","initial_response_message_worker_address_record_url":"U","initial_response_message_worker_address_org__label":"context_url","initial_response_message_worker_address_org_id":"N","initial_response_message_worker_address_org_name":"S","initial_response_message_worker_address_org_city":"S","initial_response_message_worker_address_org_country":"S","initial_response_message_worker_address_org_created":"E","initial_response_message_worker_address_org_phone":"phone","initial_response_message_worker_address_org_postal":"S","initial_response_message_worker_address_org_province":"S","initial_response_message_worker_address_org_street":"S","initial_response_message_worker_address_org_updated":"E","initial_response_message_worker_address_org_website":"U","initial_response_message_worker_address_org_record_url":"U","initial_response_message_worker_calendar__label":"context_url","initial_response_message_worker_calendar_id":"N","initial_response_message_worker_calendar_name":"S","initial_response_message_worker_calendar_owner__label":"context_url","initial_response_message_worker_calendar_updated_at":"E","initial_response_message_worker_calendar_record_url":"U","latest_message__label":"context_url","latest_message_html_attachment_id":"N","latest_message_id":"N","latest_message_content":"T","latest_message_created":"E","latest_message_is_broadcast":"C","latest_message_is_not_sent":"C","latest_message_is_outgoing":"C","latest_message_response_time":"time_secs","latest_message_storage_size":"size_bytes","latest_message_record_url":"U","latest_message_headers":null,"latest_message_sender__label":"context_url","latest_message_sender_id":"N","latest_message_sender_address":"S","latest_message_sender_first_name":"S","latest_message_sender_full_name":"S","latest_message_sender_last_name":"S","latest_message_sender_num_spam":"N","latest_message_sender_num_nonspam":"N","latest_message_sender_is_banned":"C","latest_message_sender_is_contact":"C","latest_message_sender_is_defunct":"C","latest_message_sender_updated":"E","latest_message_sender_record_url":"U","latest_message_sender_org__label":"context_url","latest_message_sender_org_id":"N","latest_message_sender_org_name":"S","latest_message_sender_org_city":"S","latest_message_sender_org_country":"S","latest_message_sender_org_created":"E","latest_message_sender_org_phone":"phone","latest_message_sender_org_postal":"S","latest_message_sender_org_province":"S","latest_message_sender_org_street":"S","latest_message_sender_org_updated":"E","latest_message_sender_org_website":"U","latest_message_sender_org_record_url":"U","latest_message_worker__label":"context_url","latest_message_worker_first_name":"S","latest_message_worker_full_name":"S","latest_message_worker_id":"N","latest_message_worker_is_disabled":"C","latest_message_worker_is_superuser":"******","latest_message_worker_language":"S","latest_message_worker_last_name":"S","latest_message_worker_last_activity_date":"E","latest_message_worker_time_format":"S","latest_message_worker_timezone":"S","latest_message_worker_title":"S","latest_message_worker_updated":"E","latest_message_worker_record_url":"U","latest_message_worker_address__label":"context_url","latest_message_worker_address_id":"N","latest_message_worker_address_address":"S","latest_message_worker_address_first_name":"S","latest_message_worker_address_full_name":"S","latest_message_worker_address_last_name":"S","latest_message_worker_address_num_spam":"N","latest_message_worker_address_num_nonspam":"N","latest_message_worker_address_is_banned":"C","latest_message_worker_address_is_contact":"C","latest_message_worker_address_is_defunct":"C","latest_message_worker_address_updated":"E","latest_message_worker_address_record_url":"U","latest_message_worker_address_org__label":"context_url","latest_message_worker_address_org_id":"N","latest_message_worker_address_org_name":"S","latest_message_worker_address_org_city":"S","latest_message_worker_address_org_country":"S","latest_message_worker_address_org_created":"E","latest_message_worker_address_org_phone":"phone","latest_message_worker_address_org_postal":"S","latest_message_worker_address_org_province":"S","latest_message_worker_address_org_street":"S","latest_message_worker_address_org_updated":"E","latest_message_worker_address_org_website":"U","latest_message_worker_address_org_record_url":"U","latest_message_worker_calendar__label":"context_url","latest_message_worker_calendar_id":"N","latest_message_worker_calendar_name":"S","latest_message_worker_calendar_owner__label":"context_url","latest_message_worker_calendar_updated_at":"E","latest_message_worker_calendar_record_url":"U","owner__label":"context_url","owner_first_name":"S","owner_full_name":"S","owner_id":"N","owner_is_disabled":"C","owner_is_superuser":"******","owner_language":"S","owner_last_name":"S","owner_last_activity_date":"E","owner_time_format":"S","owner_timezone":"S","owner_title":"S","owner_updated":"E","owner_record_url":"U","owner_address__label":"context_url","owner_address_id":"N","owner_address_address":"S","owner_address_first_name":"S","owner_address_full_name":"S","owner_address_last_name":"S","owner_address_num_spam":"N","owner_address_num_nonspam":"N","owner_address_is_banned":"C","owner_address_is_contact":"C","owner_address_is_defunct":"C","owner_address_updated":"E","owner_address_record_url":"U","owner_address_org__label":"context_url","owner_address_org_id":"N","owner_address_org_name":"S","owner_address_org_city":"S","owner_address_org_country":"S","owner_address_org_created":"E","owner_address_org_phone":"phone","owner_address_org_postal":"S","owner_address_org_province":"S","owner_address_org_street":"S","owner_address_org_updated":"E","owner_address_org_website":"U","owner_address_org_record_url":"U","owner_calendar__label":"context_url","owner_calendar_id":"N","owner_calendar_name":"S","owner_calendar_owner__label":"context_url","owner_calendar_updated_at":"E","owner_calendar_record_url":"U","org__label":"context_url","org_id":"N","org_name":"S","org_city":"S","org_country":"S","org_created":"E","org_phone":"phone","org_postal":"S","org_province":"S","org_street":"S","org_updated":"E","org_website":"U","org_record_url":"U"}},"total":1}')); $client = new Client('', '', '', $curl); //when $tickets = $client->getTickets([['q', 'identifier:1557751']]); //then $this->assertEquals(1, $tickets->getTotal()); Assert::thatArray($tickets->getResults())->onProperty('mask')->containsExactly('ACB-99934-772'); }
/** * @test */ public function shouldThrowConnectionExceptionFromForPostgres() { //given Config::overrideProperty('sql_dialect')->with('\\Ouzo\\Db\\Dialect\\PostgresDialect'); Mock::when($this->pdoMock)->errorInfo()->thenReturn(array('57P01', 7, 'Execution error')); $executor = StatementExecutor::prepare($this->dbMock, 'SELECT 1', array(), array()); //when CatchException::when($executor)->execute(); //then CatchException::assertThat()->isInstanceOf('\\Ouzo\\DbConnectionException'); Config::revertProperty('sql_dialect'); }
/** * @test */ public function shouldReturnFieldsWithPrimaryKeyWhenIsDefault() { //given /** @var Dialect $dialect */ $dialect = Mock::mock('Ouzo\\Tools\\Model\\Template\\Dialect\\Dialect'); Mock::when($dialect)->primaryKey()->thenReturn('id'); Mock::when($dialect)->columns()->thenReturn(array(new DatabaseColumn('sale', 'text'), new DatabaseColumn('description', 'text'), new DatabaseColumn('id', 'int'))); $tableInfo = new TableInfo($dialect); //when $columns = $tableInfo->tableColumns; //then Assert::thatArray($columns)->onProperty('name')->containsOnly('sale', 'description', 'id'); }
/** * @test */ public function shouldAddEmptyPrimaryKeyEntryWhenNoFoundPrimaryKeyInTable() { //given /** @var Dialect $dialect */ $dialect = Mock::mock('Ouzo\\Tools\\Model\\Template\\Dialect\\Dialect'); Mock::when($dialect)->primaryKey()->thenReturn(''); Mock::when($dialect)->columns()->thenReturn(array()); $classStubReplacer = new ClassStubPlaceholderReplacer('Customer', new TableInfo($dialect)); //when $classContents = $classStubReplacer->contents(); //then Assert::thatString($classContents)->isNotEqualTo('')->contains('primaryKey'); }
/** * @test */ public function shouldNotDisplayOutputBeforeHeadersAreSent() { //given $self = $this; $obLevel = ob_get_level(); Mock::when($this->frontController->getHeaderSender())->send(Mock::any())->thenAnswer(function () use($self, $obLevel) { //if there's a nested buffer, nothing was sent to output $self->assertTrue(ob_get_level() > $obLevel); $self->expectOutputString('OUTPUT'); }); Route::allowAll('/sample', 'sample'); //when $this->get('/sample/action'); //then no exceptions }
/** * @test */ public function runInTransactionShouldInvokeRollbackOnFailure() { // given Db::getInstance()->enableTransactions(); $dbHandle = Mock::mock(); $db = new Db(false); $db->_dbHandle = $dbHandle; //when CatchException::when($db)->runInTransaction(array(new Sample(), 'exceptionMethod')); //then CatchException::assertThat()->isInstanceOf('InvalidArgumentException'); Mock::verify($dbHandle)->beginTransaction(); Mock::verify($dbHandle)->neverReceived()->commitTransaction(); Mock::verify($dbHandle)->rollBack(); }
/** * @test */ public function shouldSubstituteParams() { //given $pdoStatement = Mock::mock(); $pdo = Mock::mock(); $db = Mock::mock('Ouzo\\Db'); $db->_dbHandle = $pdo; Mock::when($pdo)->query(Mock::anyArgList())->thenReturn($pdoStatement); Mock::when($pdo)->quote("bob")->thenReturn("'bob'"); Mock::when($pdoStatement)->fetchAll(Mock::anyArgList())->thenReturn(array()); $modelQueryBuilder = new ModelQueryBuilder(SimpleModel::metaInstance(), $db); //when $modelQueryBuilder->where(array('name' => 'bob'))->options(array(Options::EMULATE_PREPARES => true))->fetchAll(); //then Mock::verify($pdo)->query("SELECT simple_models.name AS _simple_models_name, simple_models.id AS _simple_models_id FROM simple_models WHERE name = 'bob'"); }
/** * @test */ public function shouldCompareByExpression() { //given $mock1 = Mock::mock('Foo'); Mock::when($mock1)->method()->thenReturn(1); $mock2 = Mock::mock('Foo'); Mock::when($mock2)->method()->thenReturn(2); $comparator = Comparator::compareBy('method()'); //when $lesser = $comparator($mock1, $mock2); $greater = $comparator($mock2, $mock1); $equal = $comparator($mock1, $mock1); //then $this->assertEquals(-1, $lesser); $this->assertEquals(1, $greater); $this->assertEquals(0, $equal); }
/** * @test */ public function memoizeShouldCacheResult() { //given $command = Mock::mock(); Mock::when($command)->getName()->thenReturn('Jack', 'Black', 'White'); $supplier = Suppliers::memoize(function () use($command) { return $command->getName(); }); //when Clock::freeze('2014-01-01 11:11:11'); $result1 = $supplier->get(); $result2 = $supplier->get(); Clock::freeze('2014-01-01 11:11:12'); $result3 = $supplier->get(); Clock::freeze('2014-01-01 11:11:22'); $result4 = $supplier->get(); $result5 = $supplier->get(); //then $this->assertEquals('Jack', $result1); $this->assertEquals('Jack', $result2); $this->assertEquals('Jack', $result3); $this->assertEquals('Jack', $result4); $this->assertEquals('Jack', $result5); }
/** * @test */ public function shouldBeInstanceOf() { // then GeneralAssert::that(new stdClass())->isInstanceOf('stdClass'); GeneralAssert::that(Mock::create('stdClass'))->isInstanceOf('stdClass'); }
private function _createRouter($method, $uri) { $_SERVER['REQUEST_METHOD'] = $method; $pathMock = Mock::create('\\Ouzo\\Uri\\PathProvider'); Mock::when($pathMock)->getPath()->thenReturn($uri); return new Router(new Uri($pathMock)); }
/** * @test */ public function shouldVerifyInOrder() { //given $mock = Mock::mock(); //when $mock->method2(); $mock->method1(); //then Mock::verifyInOrder(function (InOrderVerifier $inOrder) use($mock) { $inOrder->verify($mock)->method2(); $inOrder->verify($mock)->method1(); }); }
private function _path($path) { Mock::when($this->pathProviderMock)->getPath()->thenReturn($path); }
/** * @test */ public function shouldNotTryToDeleteIfEmptyInClause() { //given $mockDb = Mock::create('\\Ouzo\\Db'); $builder = new ModelQueryBuilder(new Product(), $mockDb); //when $affectedRows = $builder->where(array('name' => array()))->deleteAll(); //then $this->assertEquals(0, $affectedRows); //no interaction with db Mock::verify($mockDb)->neverReceived(); }
/** * @test */ public function shouldNotCallMapFunctionOnSkippedElements() { //given $iterator = new \ArrayIterator(array(1, 2, 3)); $mapper = Mock::create(); Mock::when($mapper)->map(Mock::anyArgList())->thenAnswer(function (MethodCall $methodCall) { return Arrays::first($methodCall->arguments); }); //when $result = FluentIterator::from($iterator)->map(function ($elem) use($mapper) { return $mapper->map($elem); })->skip(1)->limit(1); //then $this->assertEquals(array(2), array_values($result->toArray())); Mock::verify($mapper)->neverReceived()->map(1); Mock::verify($mapper)->neverReceived()->map(3); }