Inheritance: extends WP_UnitTest_Factory_For_Thing
 public function create($args = [])
 {
     if (!isset($args['post_id']) || !$args['post_id']) {
         $post_factory = new WP_UnitTest_Factory_For_Post($this->factory);
         $args['post_id'] = $post_factory->create(['post_type' => 'podcast']);
     } else {
         // just make sure the connected post has the correct post type
         wp_update_post(['ID' => $args['post_id'], 'post_type' => 'podcast']);
     }
     return \Podlove\Model\Episode::create($args);
 }
 /**
  * Create a product.
  *
  * @param array $args
  *
  * @return int|WP_Error
  */
 function create_object($args)
 {
     $args['post_type'] = 'it_exchange_prod';
     $args['post_status'] = 'publish';
     $product_id = parent::create_object($args);
     if (is_wp_error($product_id) || !$product_id) {
         return $product_id;
     }
     $defaults = array('product_type' => 'digital-downloads-product-type', 'show_in_store' => true, 'limit' => 2, 'key-type' => 'random', 'version' => '1.0', 'base-price' => '99.00', 'update-file' => '');
     $args = wp_parse_args($args, $defaults);
     if (empty($args['update-file'])) {
         $name = get_the_title($product_id);
         $name .= '.zip';
         $attachment_factory = new WP_UnitTest_Factory_For_Attachment();
         $attachment_id = $attachment_factory->create_object($name, $product_id, array('post_mime_type' => 'application/zip'));
         $download_id = parent::create_object(array('post_type' => 'it_exchange_download'));
         update_post_meta($download_id, '_it-exchange-download-info', array('source' => wp_get_attachment_url($attachment_id), 'product_id' => $product_id, 'download_id' => $download_id, 'name' => $name));
         $args['update-file'] = $download_id;
     }
     if (!empty($args['product_type'])) {
         update_post_meta($product_id, '_it_exchange_product_type', $args['product_type']);
     }
     update_post_meta($product_id, '_it-exchange-visibility', empty($args['show_in_store']) ? 'hidden' : 'visible');
     it_exchange_update_product_feature($product_id, 'licensing', array('enabled' => true, 'limit' => $args['limit'], 'key-type' => $args['key-type'], 'version' => $args['version'], 'update-file' => $args['update-file']));
     if (isset($args['interval'])) {
         it_exchange_update_product_feature($product_id, 'recurring-payments', 'on');
         it_exchange_update_product_feature($product_id, 'recurring-payments', $args['interval'], array('setting' => 'interval'));
         it_exchange_update_product_feature($product_id, 'recurring-payments', $args['interval-count'], array('setting' => 'interval-count'));
     }
     return $product_id;
 }
 /**
  * Create a mock webhook
  *
  * @since 2.2
  * @see WP_UnitTest_Factory_For_Post::create_object()
  * @param array $args
  * @return int webhook (post) ID
  */
 public function create_object($args)
 {
     $id = parent::create_object($args);
     $meta_args = array('_topic' => 'coupon.created', '_resource' => 'coupon', '_event' => 'created', '_hooks' => array('woocommerce_process_shop_coupon_meta', 'woocommerce_api_create_coupon'), '_delivery_url' => 'http://requestb.in/Tt8675309');
     foreach ($meta_args as $key => $value) {
         update_post_meta($id, $key, $value);
     }
     return $id;
 }
Example #4
0
 /**
  * @param $args
  *
  * @return int|WP_Error
  */
 function create_object($args)
 {
     $args = wp_parse_args($args, $this->default_generation_definitions);
     $form_id = $args['form_id'];
     $template_id = isset($args['template_id']) ? $args['template_id'] : 'preset_business_data';
     $settings = isset($args['settings']) ? $args['settings'] : GravityView_View_Data::get_default_args();
     $fields = isset($args['fields']) ? serialize($args['fields']) : 'a:1:{s:23:"directory_table-columns";a:3:{s:13:"535d63d1488b0";a:9:{s:2:"id";s:1:"4";s:5:"label";s:13:"Business Name";s:10:"show_label";s:1:"1";s:12:"custom_label";s:0:"";s:12:"custom_class";s:0:"";s:12:"show_as_link";s:1:"0";s:13:"search_filter";s:1:"0";s:13:"only_loggedin";s:1:"0";s:17:"only_loggedin_cap";s:4:"read";}s:13:"535d63d379a3c";a:9:{s:2:"id";s:2:"12";s:5:"label";s:20:"Business Description";s:10:"show_label";s:1:"1";s:12:"custom_label";s:0:"";s:12:"custom_class";s:0:"";s:12:"show_as_link";s:1:"0";s:13:"search_filter";s:1:"0";s:13:"only_loggedin";s:1:"0";s:17:"only_loggedin_cap";s:4:"read";}s:13:"535d63dc735a6";a:9:{s:2:"id";s:1:"2";s:5:"label";s:7:"Address";s:10:"show_label";s:1:"1";s:12:"custom_label";s:0:"";s:12:"custom_class";s:0:"";s:12:"show_as_link";s:1:"0";s:13:"search_filter";s:1:"0";s:13:"only_loggedin";s:1:"0";s:17:"only_loggedin_cap";s:4:"read";}}}';
     $insert_post_response = parent::create_object($args);
     if ($insert_post_response && !is_wp_error($insert_post_response)) {
         $view_meta = array('_gravityview_form_id' => $form_id, '_gravityview_template_settings' => $settings, '_gravityview_directory_template' => $template_id, '_gravityview_directory_widgets' => 'a:0:{}', '_gravityview_directory_fields' => $fields);
         foreach ($view_meta as $meta_key => $meta_value) {
             $meta_value = maybe_unserialize($meta_value);
             update_post_meta($insert_post_response, $meta_key, $meta_value);
         }
     }
     return $insert_post_response;
 }
Example #5
0
 public function get_object_by_id($paper_id)
 {
     return parent::get_object_by_id($paper_id);
 }
Example #6
0
 function __construct($post_type, $factory = null)
 {
     parent::__construct($factory);
     $this->default_generation_definitions['post_type'] = $post_type;
 }
Example #7
0
 function __construct($factory = null)
 {
     parent::__construct($factory);
     $this->default_generation_definitions = array('post_status' => 'publish', 'post_title' => new WP_UnitTest_Generator_Sequence('Post title %s'), 'post_content' => new WP_UnitTest_Generator_Sequence('Post content %s'), 'post_excerpt' => new WP_UnitTest_Generator_Sequence('Post excerpt %s'), 'post_type' => 'gistpen');
 }
 public function create_object($args)
 {
     $args['post_type'] = 'webwork_probinstance';
     $post_id = parent::create_object($args);
     if (!$post_id || is_wp_error($post_id)) {
         return $post_id;
     }
     $pi = new \WeBWorK\Server\ProblemInstance($post_id);
     $clean_pi = clone $pi;
     $problem_id = isset($args['problem_id']) ? $args['problem_id'] : '';
     if ($problem_id) {
         $pi->set_problem_id($problem_id);
     }
     $remote_course_url = isset($args['remote_course_url']) ? $args['remote_course_url'] : '';
     $pi->set_remote_course_url($remote_course_url);
     $remote_problem_url = isset($args['remote_problem_url']) ? $args['remote_problem_url'] : '';
     $pi->set_remote_problem_url($remote_problem_url);
     $remote_problem_set = isset($args['remote_problem_set']) ? $args['remote_problem_set'] : '';
     $pi->set_remote_problem_set($remote_problem_set);
     $remote_problem = isset($args['remote_problem']) ? $args['remote_problem'] : '';
     $pi->set_remote_problem($remote_problem);
     if (isset($args['post_date'])) {
         $pi->set_post_date($args['post_date']);
     }
     if ($clean_pi != $pi) {
         $pi->save();
     }
     return $post_id;
 }