Пример #1
0
 public function setUp()
 {
     global $wpdb;
     parent::setUp();
     register_taxonomy('edu_test_tax_1', 'post');
     register_taxonomy('edu_test_tax_2', 'post');
     $t1 = wp_insert_term('Edu', 'edu_test_tax_1');
     $t2 = wp_insert_term('Edu', 'edu_test_tax_2');
     $t3 = wp_insert_term('Edu', 'ib_educator_category');
     $t4 = wp_insert_term('Mathematics', 'ib_educator_category');
     // Arbitrary term.
     $wpdb->update($wpdb->term_taxonomy, array('term_id' => $t1['term_id']), array('term_taxonomy_id' => $t2['term_taxonomy_id']), array('%d'), array('%d'));
     $wpdb->update($wpdb->term_taxonomy, array('term_id' => $t1['term_id']), array('term_taxonomy_id' => $t3['term_taxonomy_id']), array('%d'), array('%d'));
     $t2['term_id'] = $t1['term_id'];
     $t3['term_id'] = $t1['term_id'];
     // Create membership.
     $post_id = wp_insert_post(array('post_type' => 'ib_edu_membership', 'post_name' => 'edu-membership-1', 'post_title' => 'edu membership 1', 'post_status' => 'publish'));
     $ms = Edr_Memberships::get_instance();
     $meta = $ms->get_membership_meta();
     $meta['price'] = '10.05';
     $meta['period'] = '';
     $meta['duration'] = '';
     $meta['categories'] = array($t3['term_id'], $t4['term_id']);
     update_post_meta($post_id, '_ib_educator_membership', $meta);
     $this->posts[] = $post_id;
     $this->terms = array('term1' => $t1, 'term2' => $t2, 'term3' => $t3, 'term4' => $t4);
 }
    /**
     * Setup the tests object.
     */
    public function setUp()
    {
        parent::setUp();
        $this->basicSetUp();
        // Lesson with more tag only.
        $lesson1 = get_post($this->lessons[0]);
        $lesson1->post_excerpt = '';
        $lesson1->post_content = <<<EOT
This text can be visible to anyone.<!--more-->
This text must be visible to the students who registered for this course.
EOT;
        wp_update_post($lesson1);
        // Lesson without more tag and excerpt.
        $lesson2 = get_post($this->lessons[1]);
        $lesson2->post_excerpt = '';
        $lesson2->post_content = <<<EOT
This text must be visible to the students who registered for this course.
EOT;
        wp_update_post($lesson2);
        // Lesson with excerpt only.
        $this->lesson3 = $this->addLesson(array('course_id' => $this->courses[0], 'author_id' => $this->users['lecturer1'], 'slug' => 'course-1-lesson-3', 'title' => 'course 1 lesson 3'));
        $lesson3 = get_post($this->lesson3);
        $lesson3->post_excerpt = 'This excerpt is visible to everyone.';
        $lesson3->post_content = <<<EOT
This text must be visible to the students who registered for this course.
EOT;
        wp_update_post($lesson3);
        $this->open_lesson = $this->addLesson(array('course_id' => $this->courses[0], 'author_id' => $this->users['lecturer1'], 'slug' => 'course-1-open-lesson', 'title' => 'course 1 open lesson'));
        $open_lesson = get_post($this->open_lesson);
        $open_lesson->post_excerpt = 'Post excerpt.';
        $open_lesson->post_content = 'Hidden content.';
        wp_update_post($open_lesson);
    }
Пример #3
0
 public function setUp()
 {
     parent::setUp();
     $this->basicSetUp();
     // Add questions.
     $this->addQuestion(array('lesson_id' => $this->lessons[0], 'question' => 'Question #1', 'question_type' => 'multiplechoice', 'menu_order' => 0));
     $this->addQuestion(array('lesson_id' => $this->lessons[0], 'question' => 'Question #2', 'question_type' => 'multiplechoice', 'menu_order' => 1));
     // Set attempts number to 3.
     update_post_meta($this->lessons[0], '_edr_attempts', 3);
     // Add 1 attempt.
     $this->addAttempt();
 }
Пример #4
0
 /**
  * Setup initial tests data.
  */
 public function setUp()
 {
     parent::setUp();
     $this->basicSetUp();
     $ms = Edr_Memberships::get_instance();
     // Add categories to courses.
     wp_set_post_terms($this->courses[0], array($this->categories[0]), 'ib_educator_category');
     wp_set_post_terms($this->courses[1], array($this->categories[1], $this->categories[2]), 'ib_educator_category');
     // This membership gives access to the first course only.
     $this->memberships['months'] = $this->addMembership(array('price' => 187.32, 'period' => 'months', 'duration' => 3, 'categories' => array($this->categories[0])));
     // Expired membership.
     $this->memberships['expired'] = $this->addMembership(array('price' => 1283.32, 'period' => 'days', 'duration' => 10, 'categories' => array($this->categories[1])));
     // Setup payment for the membership.
     $this->payments['membership_months'] = $this->addPayment(array('payment_type' => 'membership', 'payment_status' => 'complete', 'object_id' => $this->memberships['months'], 'user_id' => $this->users['student1']));
     // Setup membership for the student.
     $ms->setup_membership($this->users['student1'], $this->memberships['months']);
     $ms->setup_membership($this->admin_id, $this->memberships['expired']);
 }
Пример #5
0
 /**
  * Setup tests.
  */
 public function setUp()
 {
     parent::setUp();
     $this->basicSetUp();
 }