12 public $fixtures = array(
16 public $bulkController;
18 public static function setUpBeforeClass(){
20 Yii::app()->getModule(
'bulk')->setImport(array(
'bulk.controllers.*'));
23 public function setUp(){
28 $this->bulkController->actionClear(
'all');
30 $bufferClearResults = ob_get_contents();
33 preg_match(
"/Clear complete/", $bufferClearResults, $match);
34 $this->assertNotEmpty($match,
"Clear failed");
37 public function testBulkUsers(){
39 $_GET[
'GenerationForm'] = array(
44 'commentsForEach'=>
"0",
45 'commentsContentId'=>
""
49 $this->bulkController->actionGenerate();
51 $bufferAddUsersResults = ob_get_contents();
54 preg_match(
"/Generation complete/s", $bufferAddUsersResults, $match);
55 $this->assertNotEmpty($match,
"Users were not added");
57 $usersQty =
User::model()->count(
'is_bulk = :is_bulk', array(
':is_bulk' =>
true));
58 $this->assertEquals($usersQty, 5,
"Incorrect count of the bulk users");
60 preg_match(
"/Users: (?P<count>\d+)/s", $bufferAddUsersResults, $match);
61 $this->assertNotEmpty($match,
"Users addition failed");
63 $this->bulkComments();
68 public function bulkComments(){
70 $_GET[
'GenerationForm'] = array(
75 'commentsForEach'=>
"0",
76 'commentsContentId'=>
""
80 $this->bulkController->actionGenerate();
82 $bufferAddCommentsResults = ob_get_contents();
85 preg_match(
"/Generation complete/s", $bufferAddCommentsResults, $match);
86 $this->assertNotEmpty($match,
"Comments were not added");
88 $commentsQty = Yii::app()->db->createCommand()
91 ->join(
User::model()->tableName() .
' as u',
'u.id = user_id')
92 ->where(
'is_bulk = :is_bulk', array(
':is_bulk' =>
true))
95 $this->assertEquals($commentsQty, 5,
"Incorrect count of the bulk comments");
97 preg_match(
"/Comments: (?P<count>\d+)/s", $bufferAddCommentsResults, $match);
98 $this->assertNotEmpty($match,
"Comments addition failed");
101 public function bulkLikes(){
103 $_GET[
'GenerationForm'] = array(
106 'likesContentId'=>
"",
108 'commentsForEach'=>
"0",
109 'commentsContentId'=>
""
113 $this->bulkController->actionGenerate();
115 $bufferAddLikesResults = ob_get_contents();
118 preg_match(
"/Generation complete/s", $bufferAddLikesResults, $match);
119 $this->assertNotEmpty($match,
"Likes were not added");
121 $likesQty = Yii::app()->db->createCommand()
124 ->join(
User::model()->tableName() .
' as u',
'u.id = user_id')
125 ->where(
'is_bulk = :is_bulk', array(
':is_bulk' =>
true))
128 $this->assertEquals($likesQty, 5,
"Incorrect count of the bulk likes");
130 preg_match(
"/Likes: (?P<count>\d+)/s", $bufferAddLikesResults, $match);
131 $this->assertNotEmpty($match,
"Likes addition failed");
134 $this->assertEquals($match[
'count'], 5,
"Incorrect count of the inserts is shown");