14 public static function setUpBeforeClass()
17 parent::setUpBeforeClass();
26 $comment->attributes = $attributes;
27 $this->assertTrue($comment->save());
38 $this->assertCount(1,
Comment::model()->findAllByAttributes($attributes));
48 $this->assertNotEmpty(
Comment::model()->findByAttributes($attributes)->hash());
57 $this->assertEquals(1,
Comment::model()->deleteAllByAttributes($attributes));
61 public function testValidateEmail()
64 $comment->email =
'not valid';
65 $comment->moderator_email =
'not valid';
67 $this->assertNotNull($comment->getError(
'email'));
68 $this->assertNotNull($comment->getError(
'moderator_email'));
70 $comment->email =
'valid@email.com';
71 $comment->moderator_email =
'valid@email.com';
73 $this->assertNull($comment->getError(
'email'));
74 $this->assertNull($comment->getError(
'moderator_email'));
77 public function testCreateAnonymousScope()
79 $comment =
new Comment(
'createAnonymous');
80 $comment->attributes = array(
83 'moderator_email' =>
'email@email.com',
84 'email' =>
'email@email.com',
85 'subject' =>
'Subject',
86 'description' =>
'Description',
87 'notify_moderator' => 0,
93 $this->assertTrue($comment->hasErrors(
'firstname'));
94 $this->assertTrue($comment->hasErrors(
'lastname'));
96 $comment->firstname =
'Ivan';
97 $comment->lastname =
'Pupkin';
99 $this->assertFalse($comment->hasErrors(
'firstname'));
100 $this->assertFalse($comment->hasErrors(
'lastname'));
104 public function testCreateScope()
106 $comment =
new Comment(
'create');
107 $comment->attributes = array(
110 'moderator_email' =>
'email@email.com',
111 'email' =>
'email@email.com',
112 'subject' =>
'Subject',
113 'description' =>
'Description',
114 'notify_moderator' => 0,
119 $this->assertTrue($comment->validate());
122 public function provider()
129 'moderator_email' =>
'email@email.com',
130 'firstname' =>
'First name',
131 'lastname' =>
'Last name',
132 'email' =>
'email@email.com',
133 'subject' =>
'Subject',
134 'description' =>
'Description',
135 'notify_moderator' => 0,
144 'moderator_email' =>
'email@email.com',
145 'firstname' =>
'First name',
146 'lastname' =>
'Last name',
147 'email' =>
'email@email.com',
148 'subject' =>
'Subject',
149 'description' =>
'Description',
150 'notify_moderator' => 1,
159 'moderator_email' =>
'email@email.com',
160 'firstname' =>
'First name',
161 'lastname' =>
'Last name',
162 'email' =>
'email@email.com',
163 'subject' =>
'Subject',
164 'description' =>
'Description',
165 'notify_moderator' => 1,
167 'status' => Comment::APPROVED,
172 'content_id' =>
'STRING_ID',
174 'moderator_email' =>
'email@email.com',
175 'firstname' =>
'First name',
176 'lastname' =>
'Last name',
177 'email' =>
'email@email.com',
178 'subject' =>
'Subject',
179 'description' =>
'Description',
180 'notify_moderator' => 1,
182 'status' => Comment::APPROVED,
189 'moderator_email' =>
'email@email.com',
190 'firstname' =>
'First name',
191 'lastname' =>
'Last name',
192 'email' =>
'email@email.com',
193 'subject' =>
'Subject',
194 'description' =>
'Description',
195 'notify_moderator' => 1,
197 'status' => Comment::APPROVED,
203 public function testSearch()
205 $this->assertInstanceOf(
'CActiveDataProvider',
Comment::model()->search());