/** * @depends testPostGameNotificationToProfile */ public function testPostingAnNoteCarriesPermissionsCorrectly() { if (!SECURITY_OPTIMIZED) { return; } $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super'); $socialItems = SocialItem::getAll(); $this->assertEquals(2, count($socialItems)); $superAccountId = self::getModelIdByModelNameAndName('Account', 'superAccount'); $activityItemPostData = array('Account' => array('id' => $superAccountId)); $this->setGetArray(array('redirectUrl' => 'someRedirect')); $this->setPostArray(array('ActivityItemForm' => $activityItemPostData, 'postToProfile' => true, 'Note' => array('description' => 'a note that is promoted'))); $content = $this->runControllerWithRedirectExceptionAndGetContent('notes/default/inlineCreateSave'); $notes = Note::getAll(); $this->assertEquals(1, count($notes)); $socialItems = SocialItem::getAll(); $this->assertEquals(3, count($socialItems)); $this->assertEquals($notes[0]->id, $socialItems[2]->note->id); $this->assertNull($socialItems[2]->description); }
/** * @depends testAddingComments */ public function testDeleteSocialItem() { $socialItems = SocialItem::getAll(); $this->assertEquals(1, count($socialItems)); $comments = Comment::getAll(); $this->assertEquals(1, count($comments)); $fileModels = FileModel::getAll(); $this->assertEquals(1, count($fileModels)); foreach ($socialItems as $socialItem) { $socialItemId = $socialItem->id; $socialItem->forget(); $socialItem = SocialItem::getById($socialItemId); $deleted = $socialItem->delete(); $this->assertTrue($deleted); } $socialItems = SocialItem::getAll(); $this->assertEquals(0, count($socialItems)); //check that all comments are removed, since they are owned. $comments = Comment::getAll(); $this->assertEquals(0, count($comments)); $fileModels = FileModel::getAll(); $this->assertEquals(0, count($fileModels)); }
public function testAddingNoteAndDeletingNoteAndThenTheSocialItemsAreRemoved() { $super = User::getByUsername('super'); $this->assertEquals(0, count(SocialItem::getAll())); $accounts = Account::getByName('anAccount'); $note = NoteTestHelper::createNoteWithOwnerAndRelatedAccount('aNote', $super, $accounts[0]); $socialItem = new SocialItem(); $socialItem->description = 'My test description'; $socialItem->note = $note; $saved = $socialItem->save(); $this->assertTrue($saved); $socialItemId = $socialItem->id; $noteId = $note->id; $note->forget(); $this->assertEquals(1, count(SocialItem::getAll())); $note = Note::getById($noteId); $deleted = $note->delete(); $this->assertTrue($deleted); $this->assertEquals(0, count(SocialItem::getAll())); }