Пример #1
0
 /**
  * Tests this month testimonial retrieval.
  */
 public function testCurrentTestimonial()
 {
     $this->assertNull(Testimonial::getCurrentTestimonial());
     $testi = $this->testimonials('testimonial1');
     $currentTimestamp = date('Y-m-d H:i:s');
     $testi->status = Testimonial::STATUS_NEW;
     $testi->timestamp = $currentTimestamp;
     $this->assertTrue($testi->save());
     $this->assertNull(Testimonial::getCurrentTestimonial());
     $student = $this->students('student1');
     $content = 'Test content.';
     $newTesti = new Testimonial();
     $newTesti->setAttributes(array('content' => 'Test content.', 'status' => Testimonial::STATUS_APPROVED, 'timestamp' => $currentTimestamp, 'student_id' => $student->id));
     $this->assertTrue($newTesti->save());
     $testi = Testimonial::getCurrentTestimonial();
     $this->assertNotNull($testi);
     $this->assertTrue($testi instanceof Testimonial);
     $this->assertEquals($student->id, $testi->student_id);
     $this->assertEquals($content, $testi->content);
     $this->assertEquals(Testimonial::STATUS_APPROVED, $testi->status);
     $this->assertEquals(date('m', strtotime($currentTimestamp)), date('m', strtotime($testi->timestamp)));
     $this->assertEquals($student->id, $testi->student_id);
 }