2018-04-27 11:19:02 +03:00
|
|
|
<?php
|
|
|
|
|
2019-03-20 15:51:31 +03:00
|
|
|
/**
|
|
|
|
* Class WC_Retailcrm_Test_Case_Helper
|
|
|
|
*/
|
2018-04-27 11:19:02 +03:00
|
|
|
class WC_Retailcrm_Test_Case_Helper extends WC_Unit_Test_Case
|
|
|
|
{
|
2019-03-20 15:51:31 +03:00
|
|
|
/**
|
|
|
|
* @return array
|
|
|
|
*/
|
2020-07-10 13:14:03 +03:00
|
|
|
protected function setOptions()
|
2018-04-27 11:19:02 +03:00
|
|
|
{
|
|
|
|
$options = array(
|
|
|
|
'api_url' => 'https://example.retailcrm.ru',
|
2021-12-20 11:41:41 +03:00
|
|
|
'api_key' => 'test_key',
|
|
|
|
'corporate_enabled' => 'yes',
|
|
|
|
'online_assistant' => 'code',
|
2018-04-27 11:19:02 +03:00
|
|
|
'p_draft' => 'no',
|
|
|
|
'p_pending' => 'no',
|
|
|
|
'p_private' => 'no',
|
|
|
|
'p_publish' => 'no',
|
2021-12-20 11:41:41 +03:00
|
|
|
'order_methods' => array(0 => 'phone'),
|
2018-07-19 12:16:30 +03:00
|
|
|
'flat_rate_shipping' => 'delivery',
|
|
|
|
'free_shipping' => 'delivery2',
|
|
|
|
'local_pickup' => 'delivery3',
|
2018-04-27 11:19:02 +03:00
|
|
|
'bacs' => 'payment1',
|
|
|
|
'cheque' => 'payment2',
|
|
|
|
'cod' => 'payment3',
|
|
|
|
'paypal' => 'payment4',
|
|
|
|
'ppec_paypal' => 'payment5',
|
|
|
|
'pending' => 'status1',
|
|
|
|
'processing' => 'status2',
|
|
|
|
'on-hold' => 'status3',
|
|
|
|
'completed' => 'status4',
|
|
|
|
'cancelled' => 'status5',
|
|
|
|
'refunded' => 'status6',
|
|
|
|
'failed' => 'status7',
|
2021-12-20 11:41:41 +03:00
|
|
|
'sync' => 'yes',
|
2018-05-28 12:56:19 +03:00
|
|
|
'ua' => 'yes',
|
|
|
|
'ua_code' => 'UA-XXXXXXX-XX',
|
|
|
|
'ua_custom' => '1',
|
2021-12-20 11:41:41 +03:00
|
|
|
'daemon_collector' => 'yes',
|
|
|
|
'upload-button' => '',
|
|
|
|
'whatsapp_active' => 'yes',
|
|
|
|
'whatsapp_location_icon' => 'yes',
|
|
|
|
'whatsapp_number' => '+79184567234',
|
|
|
|
'icml' => 'yes',
|
|
|
|
'single_order' => '123',
|
|
|
|
'history' => 'yes',
|
|
|
|
'deactivate_update_order' => 'no',
|
|
|
|
'bind_by_sku' => 'no',
|
|
|
|
'update_number' => 'yes',
|
|
|
|
'debug_mode' => 'yes',
|
|
|
|
'debug-info' => ''
|
2018-04-27 11:19:02 +03:00
|
|
|
);
|
|
|
|
|
|
|
|
update_option(WC_Retailcrm_Base::$option_key, $options);
|
|
|
|
|
|
|
|
return $options;
|
|
|
|
}
|
2019-03-20 15:51:31 +03:00
|
|
|
|
2020-07-10 13:14:03 +03:00
|
|
|
/**
|
|
|
|
* Removes all data from the DB.
|
|
|
|
*/
|
|
|
|
protected function deleteAllData()
|
|
|
|
{
|
|
|
|
if (function_exists('_delete_all_data')) {
|
|
|
|
_delete_all_data();
|
|
|
|
} else {
|
|
|
|
global $wpdb;
|
|
|
|
|
|
|
|
foreach ( array(
|
|
|
|
$wpdb->posts,
|
|
|
|
$wpdb->postmeta,
|
|
|
|
$wpdb->comments,
|
|
|
|
$wpdb->commentmeta,
|
|
|
|
$wpdb->term_relationships,
|
|
|
|
$wpdb->termmeta,
|
|
|
|
) as $table ) {
|
|
|
|
//phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
|
|
|
|
$wpdb->query( "DELETE FROM {$table}" );
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach ( array(
|
|
|
|
$wpdb->terms,
|
|
|
|
$wpdb->term_taxonomy,
|
|
|
|
) as $table ) {
|
|
|
|
//phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
|
|
|
|
$wpdb->query( "DELETE FROM {$table} WHERE term_id != 1" );
|
|
|
|
}
|
|
|
|
|
|
|
|
$wpdb->query( "UPDATE {$wpdb->term_taxonomy} SET count = 0" );
|
|
|
|
|
|
|
|
$wpdb->query( "DELETE FROM {$wpdb->users} WHERE ID != 1" );
|
|
|
|
$wpdb->query( "DELETE FROM {$wpdb->usermeta} WHERE user_id != 1" );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-20 15:51:31 +03:00
|
|
|
/**
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
protected function getOptions()
|
|
|
|
{
|
|
|
|
return get_option(WC_Retailcrm_Base::$option_key);
|
|
|
|
}
|
2021-12-20 11:41:41 +03:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param $mock
|
|
|
|
* @param $method
|
|
|
|
* @param $response
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
protected function setMockResponse($mock, $method, $response)
|
|
|
|
{
|
|
|
|
$mock->expects($this->any())
|
|
|
|
->method($method)
|
|
|
|
->willReturn($response);
|
|
|
|
}
|
2019-03-20 15:51:31 +03:00
|
|
|
}
|