public function create_object($args) { $args['post_type'] = 'webwork_question'; $post_id = parent::create_object($args); if (!$post_id || is_wp_error($post_id)) { return $post_id; } $question = new \WeBWorK\Server\Question($post_id); $clean_question = clone $question; $problem_id = isset($args['problem_id']) ? (int) $args['problem_id'] : false; if ($problem_id) { $question->set_problem_id($problem_id); } $content = isset($args['content']) ? $args['content'] : ''; $question->set_content($content); $tried = isset($args['tried']) ? $args['tried'] : ''; $question->set_tried($tried); if (isset($args['post_date'])) { $question->set_post_date($args['post_date']); } if ($clean_question != $question) { $question->save(); } return $post_id; }
public function test_set_post_date() { $q = self::factory()->question->create(); $question = new \WeBWorK\Server\Question($q); $new_date = '2015-05-05 05:05:05'; $question->set_post_date($new_date); $this->assertTrue($question->save()); $question2 = new \WeBWorK\Server\Question($q); $this->assertSame($new_date, $question2->get_post_date()); }