Good day
I am using PHP Symfony 1.4.20 framework for a project. I have build functional testing pages which kick off TASKS in order to, once the task completed running, capture the data from the database which it produced, and monitor the output of this asynchronous script behavior. The problem is, that when a TASK is called, it outputs all the Doctrine queries and TASK output which, when performing a test:all, produces dubious output, even though the test cases all succeed. My Question: How do I suppress this output from my functional test script?
Here is an example of the TASK CALL
chdir ( sfConfig::get ( 'sf_root_dir' ) ); // Trick plugin into thinking you are in a project directory
$task = new someTask ( $this->dispatcher, new sfFormatter () );
$task->run ( array (), array (
'limit' => '1000',
'env' => 'dev'
) );
Here is an example of the output I wish to suppress
2013-08-29 20:34:56: TASK STARTED
>> Doctrine_Connection_Statement execute : SELECT m.id AS m__id, m.subscription_id AS m__subscription_id, m.object AS m__object, m.status AS m__status, m.retries AS m__retries, m.type AS m__type, m.created_at AS m__created_at, m.updated_at AS m__updated_at FROM message_queue m WHERE (m.status = ?) LIMIT 1000 - (1)
>> Doctrine_Connection_Statement execute : SELECT s.id AS s__id, s.mobile_id AS s__mobile_id, s.campaign_id AS s__campaign_id, s.status AS s__status, s.send_content_message AS s__send_content_message, s.last_sent_content_group_rel_id AS s__last_sent_content_group_rel_id, s.billed_total AS s__billed_total, s.billed_current_month AS s__billed_current_month, s.billed_count AS s__billed_count, s.created_at AS s__created_at, s.updated_at AS s__updated_at FROM subscription s WHERE (s.id = ?) - (188)
>> Doctrine_Connection_Statement execute : INSERT INTO log_tx (subscription_id, is_content_message, billing_rule_id, content_charge, toaddress, mobile_network_id, content, toc, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?) - (188, 1, 4, 250, 27820000090, 2, Test for legal mobile, SMS, 2013-08-29 20:34:56, 2013-08-29 20:34:56)
>> Doctrine_Connection_Statement execute : UPDATE message_queue SET status = ?, updated_at = ? WHERE id = ? - (0, 2013-08-29 20:34:57, 694)
2013-08-29 20:34:57: SUCCESS: Message id [694] processed to [27820000090]
2013-08-29 20:34:57: TASK COMPLETED
>> Doctrine_Connection_Statement execute : SELECT MAX(l.id) AS l__0 FROM log_tx l WHERE (l.subscription_id = ? AND l.content_charge > 0) - (188)
>> Doctrine_Connection_Statement execute : SELECT l.id AS l__id, l.toaddress AS l__toaddress, l.subscription_id AS l__subscription_id, l.mobile_network_id AS l__mobile_network_id, l.toc AS l__toc, l.content AS l__content, l.content_charge AS l__content_charge, l.delivery_status AS l__delivery_status, l.sub_code AS l__sub_code, l.result_text AS l__result_text, l.is_content_message AS l__is_content_message, l.billing_rule_id AS l__billing_rule_id, l.created_at AS l__created_at, l.updated_at AS l__updated_at FROM log_tx l WHERE (l.id = ?) - (858)
ok 2 - LogTx Content Charge Matches
You will notice ok 2 - LogTx Content Charge Matches which is a test case that passed
I have searched for this answer, but it seems like no one has had this problem before so any help will be greatly appreciated. Maybe I am doing it all wrong?
Thanks in advance...
I assume you're doing the actual assertion outside the task, in which case I think the easiest way is just to open a new output buffer and then flush it without printing like:
Any output to standard output will be caught by the output buffer and discarded after the
ob_end_clean
without printing.