예제 #1
0
 public function test409_private_and_public_enabled()
 {
     $this->upFixture(new SampleCollectionsFixture());
     $collection = SampleCollectionsFixture::getCommunityCollection(1);
     $options = ['is_private' => true, 'public_enabled' => true, 'moderation_contract' => true];
     $this->requestSetPublicOptions($collection->getId(), $options)->auth(DemoAccountFixture::getAccount()->getAPIKey())->execute()->expectStatusCode(409)->expectJSONContentType()->expectJSONBody(['success' => false, 'error' => $this->expectString()]);
 }
 public function editPersonalWithGender()
 {
     $account = DemoAccountFixture::getAccount();
     $profile = DemoProfileFixture::getProfile();
     $json = ['method' => 'fl', 'first_name' => 'Annie', 'middle_name' => 'the Best', 'last_name' => 'Mage', 'nick_name' => 'annie_bears', 'gender' => 'female'];
     $this->requestEditPersonal($profile->getId(), $json)->auth($account->getAPIKey())->execute()->expectStatusCode(200)->expectJSONBody(['entity' => ['id' => $profile->getId(), 'greetings' => ['method' => $json['greetings_method'], 'greetings' => sprintf('%s % s', $json['first_name'], $json['last_name']), 'first_name' => $json['first_name'], 'last_name' => $json['last_name'], 'middle_name' => $json['middle_name']], 'gender' => ['int' => GenderFemale::INT_CODE, 'string' => GenderFemale::STRING_CODE]]]);
 }
예제 #3
0
 public function test200UnsetTheme()
 {
     $this->upFixture(new SampleCollectionsFixture());
     $collection = SampleCollectionsFixture::getCommunityCollection(1);
     $json = ['title' => '* my edited title', 'description' => '* my edited description', 'theme_ids' => []];
     $this->requestEditCollection($collection->getId(), $json)->auth(DemoAccountFixture::getAccount()->getAPIKey())->execute()->expectStatusCode(200)->expectJSONContentType()->expectJSONBody(['success' => true, 'entity' => ['title' => $json['title'], 'description' => $json['description'], 'theme_ids' => $json['theme_ids']]]);
 }
 public function up(Application $app, EntityManager $em)
 {
     $profileId = DemoAccountFixture::getSecondAccount()->getCurrentProfile()->getId();
     $service = $app->getContainer()->get(ProfileCommunitiesService::class);
     /** @var ProfileCommunitiesService $service */
     self::$bookmarks = [1 => $service->joinToCommunity($profileId, SampleCommunitiesFixture::getCommunity(1)->getSID()), 2 => $service->joinToCommunity($profileId, SampleCommunitiesFixture::getCommunity(2)->getSID()), 3 => $service->joinToCommunity($profileId, SampleCommunitiesFixture::getCommunity(3)->getSID()), 4 => $service->joinToCommunity($profileId, SampleCommunitiesFixture::getCommunity(4)->getSID()), 5 => $service->joinToCommunity($profileId, SampleCommunitiesFixture::getCommunity(5)->getSID())];
 }
 public function testNone200()
 {
     $account = DemoAccountFixture::getAccount();
     $profile = DemoProfileFixture::getProfile();
     $this->requestBackdropNone($profile->getId())->auth($account->getAPIKey())->execute()->expectStatusCode(200)->expectJSONContentType()->expectJSONBody(['backdrop' => ['type' => 'none']]);
     $this->requestGetProfile($profile->getId())->execute()->expectStatusCode(200)->expectJSONContentType()->expectJSONBody(['entity' => ['profile' => ['backdrop' => ['type' => 'none']]]]);
 }
예제 #6
0
 public function testMoveTheme200()
 {
     $this->upFixture(new SampleThemesFixture());
     $FixtureThemeFrom = SampleThemesFixture::getTheme(1);
     $FixtureThemeTo = SampleThemesFixture::getTheme(2);
     $this->requestPostMoveTheme($FixtureThemeFrom->getId(), $FixtureThemeTo->getId(), 0)->auth(DemoAccountFixture::getAccount()->getAPIKey())->execute()->expectJSONContentType()->expectStatusCode(200)->expectJSONBody(['success' => true]);
 }
예제 #7
0
 public function up(Application $app, EntityManager $em)
 {
     $postService = $app->getContainer()->get(PostService::class);
     /** @var PostService $postService */
     for ($i = 0; $i < 10; $i++) {
         self::$posts[$i] = $postService->createPost(new CreatePostParameters(DefaultPostType::CODE_INT, DemoAccountFixture::getAccount()->getCurrentProfile()->getId(), SampleCollectionsFixture::getProfileCollection(1)->getId(), 'Demo Post Content', []));
     }
 }
예제 #8
0
 public function testDoNotResetModerationContract()
 {
     $this->upFixture(new SampleCommunitiesFixture());
     $sampleCommunity = SampleCommunitiesFixture::getCommunity(2);
     $this->requestSetPublicOptions($sampleCommunity->getId(), ['public_enabled' => true, 'moderation_contract' => true])->auth(DemoAccountFixture::getAccount()->getAPIKey())->execute()->expectStatusCode(200)->expectJSONContentType();
     $this->requestEditCommunity($sampleCommunity->getId(), ['title' => '* title_edited', 'description' => '* description_edited'])->auth(DemoAccountFixture::getAccount()->getAPIKey())->execute()->expectJSONContentType()->expectStatusCode(200);
     $this->requestGetCommunityById($sampleCommunity->getId())->auth(DemoAccountFixture::getAccount()->getAPIKey())->execute()->expectStatusCode(200)->expectJSONContentType()->expectJSONBody(['entity' => ['community' => ['id' => $sampleCommunity->getId(), 'public_options' => ['public_enabled' => false, 'moderation_contract' => true]]]]);
 }
 private function createFeedbackWithResponse() : int
 {
     $profile = DemoProfileFixture::getProfile();
     $this->requestFeedbackCreate(["profile_id" => $profile->getId(), "type_feedback" => FTCommonQuestion::INT_CODE, "description" => "Demo Feedback"])->execute()->expectJSONContentType()->expectStatusCode(200)->expectJSONBody(['success' => true, 'entity' => ['id' => $this->expectId(), 'created_at' => $this->expectString(), 'profile' => ['has' => true, 'entity' => $profile->toJSON()]]]);
     $feedbackId = (int) self::$currentResult->getContent()['entity']['id'];
     $this->requestCreateFeedbackResponse(['feedback_id' => $feedbackId, 'description' => 'Demo Feedback Response'])->auth(DemoAccountFixture::getAccount()->getAPIKey())->execute()->expectStatusCode(200)->expectJSONBody(['success' => true, 'entity' => ['id' => $this->expectId(), 'description' => $this->expectString()]]);
     return $feedbackId;
 }
예제 #10
0
 public function testCreateCommunityWithoutTheme()
 {
     $json = ['title' => 'Community 1', 'description' => 'My Community 1'];
     $this->requestCreateCommunity($json)->auth(DemoAccountFixture::getAccount()->getAPIKey())->execute()->expectJSONContentType()->expectStatusCode(200)->expectJSONBody(['success' => true, 'entity' => ['is_own' => true, 'collections' => [0 => ['id' => $this->expectId(), 'sid' => $this->expectString(), 'owner_sid' => $this->expectString(), 'owner' => ['id' => $this->expectString(), 'type' => 'community'], 'title' => $this->expectString(), 'description' => $this->expectString()]], 'community' => ['id' => $this->expectId(), 'sid' => $this->expectString(), 'title' => 'Community 1', 'description' => 'My Community 1', 'theme' => ['has' => false], 'image' => $this->expectImageCollection(), 'public_options' => ['public_enabled' => false, 'moderation_contract' => false], 'collections' => [0 => ['collection_id' => $this->expectId(), 'position' => 1]]]]])->expect(function (array $result) {
         $collections = $result['entity']['community']['collections'];
         $this->assertEquals(1, count($collections));
     });
 }
예제 #11
0
 public function testSetTheme()
 {
     $this->upFixture(new SampleCommunitiesFixture());
     $sampleCommunity = SampleCommunitiesFixture::getCommunity(2);
     $moveToTheme = SampleThemesFixture::getTheme(5);
     $this->requestEditCommunity($sampleCommunity->getId(), ['title' => '* title_edited', 'description' => '* description_edited'])->auth(DemoAccountFixture::getAccount()->getAPIKey())->execute()->expectJSONContentType()->expectStatusCode(200);
     $this->requestEditCommunity($sampleCommunity->getId(), ['title' => '* title_edited', 'description' => '* description_edited', 'theme_id' => $moveToTheme->getId()])->auth(DemoAccountFixture::getAccount()->getAPIKey())->execute()->expectJSONContentType()->expectStatusCode(200)->expectJSONBody(['success' => true, 'entity' => ['is_own' => true, 'collections' => [0 => ['id' => $this->expectId(), 'sid' => $this->expectString(), 'owner_sid' => $this->expectString(), 'owner' => ['id' => $this->expectString(), 'type' => 'community'], 'title' => $this->expectString(), 'description' => $this->expectString()]], 'community' => ['title' => '* title_edited', 'description' => '* description_edited', 'theme' => ['has' => true, 'id' => $moveToTheme->getId()]]]]);
 }
예제 #12
0
 public function testSignIn()
 {
     $this->upFixtures([new DemoAccountFixture(), new DemoProfileFixture()]);
     $account = DemoAccountFixture::getAccount();
     $profile = DemoProfileFixture::getProfile();
     $json = ['email' => $account->getEmail(), 'password' => DemoAccountFixture::ACCOUNT_PASSWORD];
     $this->requestSignIn($json)->execute()->expectStatusCode(200)->expectJSONContentType()->expectJSONBody(['success' => true, 'api_key' => $account->getAPIKey(), 'account' => ['id' => $account->getId(), 'email' => $account->getEmail(), 'disabled' => ['is_disabled' => false]], 'profiles' => [0 => ['profile' => ['id' => $profile->getId(), 'account_id' => $account->getId(), 'is_initialized' => false, 'is_current' => true], 'collections' => [0 => ['id' => $this->expectId(), 'sid' => $this->expectString(), 'title' => $this->expectString(), 'description' => $this->expectString()]]]]]);
 }
 public function testUnsetGender()
 {
     $profile = DemoProfileFixture::getProfile();
     $this->request('POST', sprintf('/protected/profile/%d/set-gender', $profile->getId()))->auth(DemoAccountFixture::getAccount()->getAPIKey())->setParameters(['gender' => 'fEmale'])->execute()->expectStatusCode(200)->expectJSONContentType();
     $this->requestGet($profile->getId())->execute()->expectJSONContentType()->expectStatusCode(200)->expectJSONBody(['success' => true, 'entity' => ['profile' => ['id' => $profile->getId(), 'gender' => ['int' => GenderFemale::INT_CODE, 'string' => GenderFemale::STRING_CODE]]]]);
     $this->request('POST', sprintf('/protected/profile/%d/set-gender', $profile->getId()))->auth(DemoAccountFixture::getAccount()->getAPIKey())->setParameters(['gender' => 'not-specified'])->execute()->expectStatusCode(200)->expectJSONContentType();
     $this->requestGet($profile->getId())->execute()->expectJSONContentType()->expectStatusCode(200)->expectJSONBody(['success' => true, 'entity' => ['profile' => ['id' => $profile->getId(), 'gender' => ['int' => GenderNotSpecified::INT_CODE, 'string' => GenderNotSpecified::STRING_CODE]]]]);
 }
예제 #14
0
 public function testGetBySID200()
 {
     $profile = DemoProfileFixture::getProfile();
     $json = ['owner_sid' => sprintf('profile:%s', $profile->getId()), 'title' => 'Demo Profile Collection', 'description' => 'My Demo Profile Collection', 'theme_ids' => [SampleThemesFixture::getTheme(1)->getId(), SampleThemesFixture::getTheme(2)->getId(), SampleThemesFixture::getTheme(3)->getId()]];
     $collectionSID = $this->requestCreateCollection($json)->auth(DemoAccountFixture::getAccount()->getAPIKey())->execute()->expectStatusCode(200)->expectJSONContentType()->expectJSONBody(['success' => true, 'entity' => ['id' => $this->expectId(), 'sid' => $this->expectString(), 'title' => $json['title'], 'description' => $json['description'], 'theme_ids' => $json['theme_ids']]])->fetch(function (array $json) {
         return $json['entity']['sid'];
     });
     $this->requestGetBySID($collectionSID)->execute()->expectStatusCode(200)->expectJSONContentType()->expectJSONBody(['entity' => ['id' => $this->expectId(), 'sid' => $collectionSID, 'title' => $json['title'], 'description' => $json['description'], 'theme_ids' => $json['theme_ids']]]);
 }
 public function test409()
 {
     $this->upFixture(new SampleCollectionsFixture());
     $community = SampleCommunitiesFixture::getCommunity(1);
     $collectionId = array_map(function (CollectionItem $item) {
         return $item->getCollectionId();
     }, $community->getCollections()->getItems())[0];
     $this->requestDeleteCollection($collectionId)->auth(DemoAccountFixture::getAccount()->getAPIKey())->execute()->expectStatusCode(409)->expectJSONContentType()->expectJSONBody(['error' => $this->expectString(), 'success' => false]);
 }
 public function testSetBirthday200()
 {
     $profile = DemoAccountFixture::getAccount()->getCurrentProfile();
     $date = $this->fromNow(-1 * (Profile::MIN_AGE + 1));
     $json = ['date' => $date->format(\DateTime::RFC2822)];
     $this->requestGetProfile($profile->getId())->execute()->expectStatusCode(200)->expectJSONContentType()->expectJSONBody(['entity' => ['profile' => ['birthday' => $this->expectUndefined()]]]);
     $this->requestSetBirthday($profile->getId(), $json)->auth(DemoAccountFixture::getAccount()->getAPIKey())->execute()->expectJSONContentType()->expectStatusCode(200)->expectJSONBody(['success' => true]);
     $this->requestGetProfile($profile->getId())->execute()->expectStatusCode(200)->expectJSONContentType()->expectJSONBody(['entity' => ['profile' => ['birthday' => $date->format(\DateTime::RFC2822)]]]);
 }
 public function testRemoveCurrentProfile()
 {
     $account = DemoAccountFixture::getAccount();
     $profile = DemoProfileFixture::getProfile();
     $result = $this->requestCreateProfile()->auth($account->getAPIKey())->execute()->expectStatusCode(200)->expectJSONContentType()->expectJSONBody(['success' => true, 'entity' => ['id' => $this->expectId(), 'is_current' => true]])->getParsedLastResult();
     $newProfileId = $result['entity']['id'];
     $this->requestDeleteProfile($newProfileId)->auth($account->getAPIKey())->execute()->expectStatusCode(200)->expectJSONContentType()->expectJSONBody(['success' => true, 'current_profile_id' => $profile->getId()]);
     $this->requestGetProfile($profile->getId())->auth($account->getAPIKey())->execute()->expectStatusCode(200)->expectJSONContentType()->expectJSONBody(['success' => true, 'entity' => ['profile' => ['is_current' => true]]]);
 }
 public function testNone200()
 {
     $this->upFixture(new SampleCommunitiesFixture());
     $account = DemoAccountFixture::getAccount();
     $profile = DemoProfileFixture::getProfile();
     $community = SampleCommunitiesFixture::getCommunity(1);
     $this->requestBackdropNone($community->getId())->auth($account->getAPIKey())->execute()->expectStatusCode(200)->expectJSONContentType()->expectJSONBody(['backdrop' => ['type' => 'none']]);
     $this->requestGetCommunityById($community->getId())->execute()->expectStatusCode(200)->expectJSONContentType()->expectJSONBody(['entity' => ['community' => ['backdrop' => ['type' => 'none']]]]);
 }
 public function testBackdropUploadTestSizes()
 {
     $account = DemoAccountFixture::getAccount();
     $profile = DemoProfileFixture::getProfile();
     $this->requestBackdropUpload($profile->getId(), __DIR__ . '/../../../Resources/grid399x399.png', 'ffffff')->auth($account->getAPIKey())->execute()->expectStatusCode(409)->expectJSONContentType()->expectJSONBody(['success' => false, 'error' => $this->expectString()]);
     $this->requestBackdropUpload($profile->getId(), __DIR__ . '/../../../Resources/grid500x500.png', 'ffffff')->auth($account->getAPIKey())->execute()->expectStatusCode(200)->expectJSONContentType()->expectJSONBody(['success' => true, 'backdrop' => ['type' => 'uploaded', 'metadata' => ['public_path' => $this->expectString(), 'storage_path' => $this->expectString(), 'text_color' => 'ffffff']]]);
     $this->requestBackdropUpload($profile->getId(), __DIR__ . '/../../../Resources/grid400x400.png', 'ffffff')->auth($account->getAPIKey())->execute()->expectStatusCode(200)->expectJSONContentType()->expectJSONBody(['success' => true, 'backdrop' => ['type' => 'uploaded', 'metadata' => ['public_path' => $this->expectString(), 'storage_path' => $this->expectString(), 'text_color' => 'ffffff']]]);
     $this->requestBackdropUpload($profile->getId(), __DIR__ . '/../../../Resources/grid2048x2048.png', 'ffffff')->auth($account->getAPIKey())->execute()->expectStatusCode(200)->expectJSONContentType()->expectJSONBody(['success' => true, 'backdrop' => ['type' => 'uploaded', 'metadata' => ['public_path' => $this->expectString(), 'storage_path' => $this->expectString(), 'text_color' => 'ffffff']]]);
     $this->requestBackdropUpload($profile->getId(), __DIR__ . '/../../../Resources/grid2049x2049.png', 'ffffff')->auth($account->getAPIKey())->execute()->expectStatusCode(409)->expectJSONContentType()->expectJSONBody(['success' => false, 'error' => $this->expectString()]);
 }
 public function testColor200()
 {
     $account = DemoAccountFixture::getAccount();
     $profile = DemoProfileFixture::getProfile();
     $this->requestGetProfile($profile->getId())->execute()->expectStatusCode(200)->expectJSONContentType()->expectJSONBody(['entity' => ['profile' => ['backdrop' => ['type' => 'preset']]]]);
     $backdropJSON = $this->requestBackdropColor($profile->getId(), 'red')->auth($account->getAPIKey())->execute()->expectStatusCode(200)->expectJSONContentType()->expectJSONBody(['backdrop' => ['type' => 'color', 'metadata' => ['palette' => ['code' => 'red', 'background' => ['code' => 'red.500', 'hexCode' => $this->expectString()], 'foreground' => ['code' => 'red.50', 'hexCode' => $this->expectString()], 'border' => ['code' => 'red.900', 'hexCode' => $this->expectString()]]]]])->fetch(function (array $json) {
         return $json['backdrop'];
     });
     $this->requestGetProfile($profile->getId())->execute()->expectStatusCode(200)->expectJSONContentType()->expectJSONBody(['entity' => ['profile' => ['backdrop' => $backdropJSON]]]);
 }
 public function testPreset200()
 {
     $account = DemoAccountFixture::getAccount();
     $profile = DemoProfileFixture::getProfile();
     $this->requestGetProfile($profile->getId())->execute()->expectStatusCode(200)->expectJSONContentType()->expectJSONBody(['entity' => ['profile' => ['backdrop' => ['type' => 'preset']]]]);
     $backdropJSON = $this->requestBackdropPreset($profile->getId(), "1")->auth($account->getAPIKey())->execute()->expectStatusCode(200)->expectJSONContentType()->expectJSONBody(['success' => true, 'backdrop' => ['type' => 'preset', 'metadata' => ['preset_id' => '1', 'public_path' => $this->expectString(), 'storage_path' => $this->expectString(), 'text_color' => '#ffffff']]])->fetch(function (array $json) {
         return $json['backdrop'];
     });
     $this->requestGetProfile($profile->getId())->execute()->expectStatusCode(200)->expectJSONContentType()->expectJSONBody(['entity' => ['profile' => ['backdrop' => $backdropJSON]]]);
 }
 public function testCreateProfile()
 {
     $account = DemoAccountFixture::getAccount();
     $profile = DemoAccountFixture::getAccount()->getCurrentProfile();
     $this->requestCreateProfile()->auth($account->getAPIKey())->execute()->expectStatusCode(200)->expectJSONContentType()->expectJSONBody(['success' => true, 'entity' => ['id' => $this->expectId(), 'sid' => $this->expectString(), 'is_current' => true, 'image' => $this->expectImageCollection(), 'backdrop' => ['type' => 'preset']]])->expect(function (array $result) {
         $collections = $result['entity']['collections'];
         $this->assertEquals(1, count($collections));
     });
     $this->requestGetProfile($profile->getId())->execute()->expectStatusCode(200)->expectJSONContentType()->expectJSONBody(['success' => true, 'entity' => ['profile' => ['id' => $profile->getId(), 'sid' => $this->expectString(), 'is_current' => false, 'image' => $this->expectImageCollection()], 'collections' => [0 => ['id' => $this->expectId(), 'sid' => $this->expectString(), 'owner_sid' => $this->expectString(), 'owner' => ['id' => $this->expectString(), 'type' => 'profile'], 'title' => $this->expectString(), 'description' => $this->expectString(), 'is_main' => true, 'is_protected' => true]]]])->expectJSONBody(['entity' => ['profile' => ['image' => ['is_auto_generated' => true]]]]);
 }
 public function testUploadImage200()
 {
     $this->upFixture(new SampleCollectionsFixture());
     $account = DemoAccountFixture::getAccount();
     $collection = SampleCollectionsFixture::getProfileCollection(1);
     $p1 = new Point(0, 0);
     $p2 = new Point(150, 150);
     $localFile = __DIR__ . '/Resources/grid-example.png';
     $this->requestUploadImage($collection->getId(), $p1, $p2, $localFile)->auth($account->getAPIKey())->execute()->expectStatusCode(200)->expectJSONContentType()->expectJSONBody(['success' => true, 'image' => $this->expectImageCollection()])->expectJSONBody(['image' => ['is_auto_generated' => false]]);
 }
 public function testImageDelete()
 {
     $account = DemoAccountFixture::getAccount();
     $profile = DemoProfileFixture::getProfile();
     $p1 = new Point(0, 0);
     $p2 = new Point(150, 150);
     $localFile = __DIR__ . '/../../../Resources/grid-example.png';
     $this->requestUploadImage($profile->getId(), $p1, $p2, $localFile)->execute()->expectAuthError();
     $this->requestUploadImage($profile->getId(), $p1, $p2, $localFile)->auth($account->getAPIKey())->execute()->expectStatusCode(200)->expectJSONContentType()->expectJSONBody(['success' => true, 'image' => $this->expectImageCollection()])->expectJSONBody(['image' => ['is_auto_generated' => false]]);
     $this->requestDeleteImage($profile->getId())->execute()->expectAuthError();
     $this->requestDeleteImage($profile->getId())->auth($account->getAPIKey())->execute()->expectStatusCode(200)->expectJSONContentType()->expectJSONBody(['success' => true, 'image' => $this->expectImageCollection()]);
     $this->requestGetProfile($profile->getId())->execute()->expectStatusCode(200)->expectJSONContentType()->expectJSONBody(['success' => true, 'entity' => ['profile' => ['image' => $this->expectImageCollection()]]])->expectJSONBody(['entity' => ['profile' => ['image' => ['is_auto_generated' => true]]]]);
 }
 public function test200()
 {
     $community = SampleCommunitiesFixture::getCommunity(1);
     $json = ['owner_sid' => sprintf('community:%s', $community->getId()), 'title' => 'Demo Community Collection', 'description' => 'My Demo Community Collection', 'theme_ids' => [SampleThemesFixture::getTheme(1)->getId(), SampleThemesFixture::getTheme(2)->getId(), SampleThemesFixture::getTheme(3)->getId()]];
     $this->requestCreateCollection($json)->auth(DemoAccountFixture::getAccount()->getAPIKey())->execute()->expectStatusCode(200)->expectJSONContentType()->expectJSONBody(['success' => true, 'entity' => ['id' => $this->expectId(), 'title' => $json['title'], 'description' => $json['description'], 'theme_ids' => $json['theme_ids'], 'image' => $this->expectImageCollection(), 'backdrop' => ['type' => 'preset']]])->expectJSONBody(['entity' => ['image' => ['is_auto_generated' => true]]]);
     $collectionId = self::$currentResult->getContent()['entity']['id'];
     $this->requestGetCommunity($community->getId())->auth(DemoAccountFixture::getAccount()->getAPIKey())->execute()->expectStatusCode(200)->expectJSONContentType()->expect(function (array $jsonResponse) use($collectionId) {
         $collections = $jsonResponse['entity']['community']['collections'];
         $this->assertTrue(is_array($collections));
         $this->assertEquals(2, count($collections));
         $this->assertEquals($collectionId, $collections[1]['collection_id']);
     });
 }
 public function testPutInterests()
 {
     $this->upFixture(new SampleThemesFixture());
     $account = DemoAccountFixture::getAccount();
     $profile = DemoProfileFixture::getProfile();
     $themeIds = [SampleThemesFixture::getTheme(1)->getId(), SampleThemesFixture::getTheme(2)->getId(), SampleThemesFixture::getTheme(3)->getId()];
     $this->requestInterestingInPUT($profile->getId(), ['theme_ids' => $themeIds])->execute()->expectAuthError();
     $this->requestInterestingInPUT($profile->getId(), ['theme_ids' => $themeIds])->auth($account->getAPIKey())->execute()->expectStatusCode(200)->expectJSONContentType()->expectJSONBody(['success' => true]);
     $this->expectInterestingInIds($profile->getId(), $themeIds);
     $newThemeIds = [SampleThemesFixture::getTheme(5)->getId(), SampleThemesFixture::getTheme(1)->getId(), SampleThemesFixture::getTheme(4)->getId()];
     $this->requestInterestingInPUT($profile->getId(), ['theme_ids' => $newThemeIds])->auth($account->getAPIKey())->execute()->expectStatusCode(200)->expectJSONContentType()->expectJSONBody(['success' => true]);
     $this->expectInterestingInIds($profile->getId(), $newThemeIds);
 }
예제 #27
0
 public function testPostCreateWithFileAttachment200()
 {
     $account = DemoAccountFixture::getAccount();
     $localFileName = __DIR__ . '/Resources/grid-example.png';
     $uploadFile = new UploadedFile($localFileName, filesize($localFileName), 0);
     $attachmentId = $this->requestUploadAttachment($uploadFile)->auth($account->getAPIKey())->execute()->expectStatusCode(200)->expectJSONContentType()->expectJSONBody(['success' => true, 'entity' => ['id' => $this->expectId()]])->fetch(function ($json) {
         return $json['entity']['id'];
     });
     $json = ["post_type" => DefaultPostType::CODE_INT, "profile_id" => $account->getCurrentProfile()->getId(), "collection_id" => SampleCollectionsFixture::getProfileCollection(1)->getId(), "content" => "Demo Post Content", "attachments" => [$attachmentId]];
     $request = $this->requestPostCreatePut($json)->auth($account->getAPIKey())->execute();
     $request->expectJSONContentType()->expectStatusCode(200)->expectJSONBody(['success' => true, 'entity' => ['id' => $this->expectId(), 'post_type' => ['int' => DefaultPostType::CODE_INT, 'string' => DefaultPostType::CODE_STRING], 'profile_id' => $json['profile_id'], 'collection_id' => $json['collection_id'], 'content' => $json['content'], 'attachments' => [0 => ['id' => $this->expectId(), 'sid' => $this->expectString(), 'date_created_on' => $this->expectString(), 'date_attached_on' => $this->expectString(), 'is_attached' => true, 'owner' => ['id' => $request->fetch(function (array $json) {
         return $json['entity']['id'];
     }), 'code' => PostAttachmentOwner::OWNER_CODE], 'link' => ['source' => ['source' => 'local', 'public_path' => $this->expectString(), 'storage_path' => $this->expectString()]]]]]]);
 }
예제 #28
0
 public function up(Application $app, EntityManager $em)
 {
     $subscribeService = $app->getContainer()->get(SubscribeService::class);
     $profile = DemoAccountFixture::getAccount()->getCurrentProfile();
     $theme = SampleThemesFixture::getTheme(1);
     self::$subscribes['theme'][0] = $subscribeService->subscribeTheme($profile, $theme);
     $subscribeProfile = DemoProfileFixture::getProfile();
     self::$subscribes['profile'][0] = $subscribeService->subscribeProfile($profile, $subscribeProfile);
     $collections = SampleCollectionsFixture::getCommunityCollections();
     $collection = array_shift($collections);
     self::$subscribes['collection'][0] = $subscribeService->subscribeCollection($profile, $collection);
     $community = SampleCommunitiesFixture::getCommunity(1);
     self::$subscribes['community'][0] = $subscribeService->subscribeCommunity($profile, $community);
 }
예제 #29
0
 public function up(Application $app, EntityManager $em)
 {
     $profile = DemoAccountFixture::getAccount()->getProfiles()->first();
     $feedbackEntities = [];
     $feedbackEntities[] = new Feedback(new FTCommonQuestion(), 'Demo Feedback 1');
     $feedbackEntities[] = new Feedback(new FTCommonQuestion(), 'Demo Feedback 2');
     $feedbackEntities[] = new Feedback(new FTCommonQuestion(), 'Demo Feedback 3', $profile);
     $feedbackEntities[] = new Feedback(new FTCommonQuestion(), 'Demo Feedback 4', $profile);
     $feedbackEntities[] = new Feedback(new FTCommonQuestion(), 'Demo Feedback 5', $profile);
     foreach ($feedbackEntities as $feedback) {
         $em->persist($feedback);
         $em->flush($feedback);
     }
     self::$fixtures = $feedbackEntities;
 }
예제 #30
0
 public function testAuthFrontline()
 {
     $account = DemoAccountFixture::getAccount();
     $profile = DemoProfileFixture::getProfile();
     $this->request('GET', '/frontline/*/')->auth($account->getAPIKey())->execute()->expectStatusCode(200)->expectJSONBody(['success' => true, 'auth' => ['api_key' => $account->getAPIKey(), 'account' => ['id' => $account->getId(), 'email' => $account->getEmail(), 'disabled' => ['is_disabled' => false]], 'profiles' => [['profile' => ['id' => $profile->getId(), 'account_id' => $account->getId(), 'is_initialized' => $profile->isInitialized(), 'is_current' => $profile->isCurrent(), 'greetings' => ['method' => $profile->getGreetings()->getMethod(), 'first_name' => $profile->getGreetings()->getFirstName(), 'last_name' => $profile->getGreetings()->getLastName(), 'middle_name' => $profile->getGreetings()->getMiddleName(), 'nick_name' => $profile->getGreetings()->getNickName()], 'image' => $this->expectImageCollection(), 'expert_in_ids' => function ($input) use($profile) {
         $this->assertTrue(is_array($input));
         $this->assertEquals($profile->getExpertInIds(), $input);
     }, 'interesting_in_ids' => function ($input) use($profile) {
         $this->assertTrue(is_array($input));
         $this->assertEquals($profile->getInterestingInIds(), $input);
     }], 'collections' => [['id' => $this->expectId(), 'sid' => $this->expectString()]]]]], 'config' => ['account' => ['delete_account_request_days' => function ($input) {
         $this->assertTrue(is_int($input));
         $this->assertGreaterThan(0, $input);
     }], 'profile' => ['max_profiles' => function ($input) {
         $this->assertTrue(is_int($input));
         $this->assertGreaterThan(0, $input);
     }], 'feedback' => ['types' => function ($input) {
         $this->assertTrue(is_array($input));
         foreach ($input as $item) {
             $this->assertTrue(is_array($item));
             $this->assertTrue(isset($item['code']) && is_array($item['code']));
             $this->assertTrue(isset($item['title']) && is_string($item['title']));
             $this->assertTrue(isset($item['description']) && is_string($item['description']));
             $code = $item['code'];
             $this->assertTrue(isset($code['int']) && is_int($code['int']));
             $this->assertTrue(isset($code['string']) && is_string($code['string']));
         }
     }], 'community' => ['features' => function ($input) {
         $this->assertTrue(is_array($input));
         foreach ($input as $item) {
             $this->assertTrue(is_array($item));
             $this->assertTrue(isset($item['code']));
             $this->assertTrue(is_string($item['code']) && strlen($item['code']) > 0);
             $this->assertTrue(isset($item['is_development_ready']) && is_bool($item['is_development_ready']));
             $this->assertTrue(isset($item['is_production_ready']) && is_bool($item['is_production_ready']));
         }
     }], 'post' => ['types' => function ($input) {
         $this->assertTrue(is_array($input));
         foreach ($input as $item) {
             $this->assertTrue(is_array($item));
             $this->assertTrue(isset($item['int']));
             $this->assertTrue(is_int($item['int']) && $item['int'] >= 0);
             $this->assertTrue(isset($item['string']));
             $this->assertTrue(is_string($item['string']) && strlen($item['string']) > 0);
         }
     }]]]);
 }