public function testPublicContent() { $this->becomeUser('User2'); $space = Space::findOne(['id' => 2]); $post1 = new Post(); $post1->message = "Private Post"; $post1->content->setContainer($space); $post1->content->visibility = Content::VISIBILITY_PRIVATE; $post1->save(); $w1 = $post1->content->getFirstWallEntryId(); $post2 = new Post(); $post2->message = "Public Post"; $post2->content->setContainer($space); $post2->content->visibility = Content::VISIBILITY_PUBLIC; $post2->save(); $w2 = $post2->content->getFirstWallEntryId(); $this->becomeUser('Admin'); $ids = $this->getStreamActionIds($space, 2); $this->assertFalse(in_array($w1, $ids)); $this->assertTrue(in_array($w2, $ids)); }
/** * Own profile content should appear with visibility Private & Public */ public function testOwnContent() { $this->becomeUser('Admin'); $post1 = new Post(); $post1->message = "Own Private Post"; $post1->content->container = Yii::$app->user->getIdentity(); $post1->content->visibility = Content::VISIBILITY_PRIVATE; $post1->save(); $w1 = $post1->content->getFirstWallEntryId(); $post2 = new Post(); $post2->message = "Own Public Post"; $post2->content->container = Yii::$app->user->getIdentity(); $post2->content->visibility = Content::VISIBILITY_PUBLIC; $post2->save(); $w2 = $post2->content->getFirstWallEntryId(); $ids = $this->getStreamActionIds(2); $this->assertEquals($ids, array($w2, $w1)); }
public function testOrder() { /** * @todo FIXME, change time in database instead of sleeping */ sleep(1); $post1 = new Post(); $post1->message = "P1"; $post1->content->setContainer(Yii::$app->user->getIdentity()); $post1->save(); $post1wallEntryId = $post1->content->getFirstWallEntryId(); sleep(1); $post2 = new Post(); $post2->message = "P2"; $post2->content->setContainer(Yii::$app->user->getIdentity()); $post2->save(); $post2wallEntryId = $post2->content->getFirstWallEntryId(); sleep(1); $post1->message = "P1b"; $post1->save(); $baseStreamAction = new Stream('stream', Yii::$app->controller); $baseStreamAction->limit = 2; $baseStreamAction->init(); $wallEntries = $baseStreamAction->getWallEntries(); $wallEntryIds = array_map(create_function('$entry', 'return $entry->id;'), $wallEntries); $this->assertEquals(array($post2wallEntryId, $post1wallEntryId), $wallEntryIds); $baseStreamAction = new Stream('stream', Yii::$app->controller); $baseStreamAction->limit = 2; $baseStreamAction->sort = Stream::SORT_UPDATED_AT; $baseStreamAction->init(); $wallEntries = $baseStreamAction->getWallEntries(); $wallEntryIds = array_map(create_function('$entry', 'return $entry->id;'), $wallEntries); $this->assertEquals(array($post1wallEntryId, $post2wallEntryId), $wallEntryIds); }