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]]]); }
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']]]]); }
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]]]]); }
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; }
public function up(Application $app, EntityManager $em) { $profile = DemoProfileFixture::getProfile(); $collectionService = $app->getContainer()->get(CollectionService::class); /** @var CollectionService $collectionService */ self::$profileCollections = [1 => $collectionService->createCollection(new CreateCollectionParameters(sprintf('profile:%s', $profile->getId()), 'Profile Collection 1', 'My Profile Collection 1', [SampleThemesFixture::getTheme(1)->getId()])), 2 => $collectionService->createCollection(new CreateCollectionParameters(sprintf('profile:%s', $profile->getId()), 'Profile Collection 1', 'My Profile Collection 2', [SampleThemesFixture::getTheme(2)->getId()])), 3 => $collectionService->createCollection(new CreateCollectionParameters(sprintf('profile:%s', $profile->getId()), 'Profile Collection 1', 'My Profile Collection 3', [SampleThemesFixture::getTheme(3)->getId()])), 4 => $collectionService->createCollection(new CreateCollectionParameters(sprintf('profile:%s', $profile->getId()), 'Profile Collection 1', 'My Profile Collection 4', [SampleThemesFixture::getTheme(4)->getId()])), 5 => $collectionService->createCollection(new CreateCollectionParameters(sprintf('profile:%s', $profile->getId()), 'Profile Collection 1', 'My Profile Collection 5', [SampleThemesFixture::getTheme(5)->getId()]))]; self::$communityCollections = [1 => $collectionService->createCollection(new CreateCollectionParameters(sprintf('community:%s', SampleCommunitiesFixture::getCommunity(1)->getId()), 'Community Collection 1', 'My Community Collection 1', [SampleThemesFixture::getTheme(1)->getId()])), 2 => $collectionService->createCollection(new CreateCollectionParameters(sprintf('community:%s', SampleCommunitiesFixture::getCommunity(2)->getId()), 'Community Collection 2', 'My Community Collection 2', [SampleThemesFixture::getTheme(2)->getId()])), 3 => $collectionService->createCollection(new CreateCollectionParameters(sprintf('community:%s', SampleCommunitiesFixture::getCommunity(3)->getId()), 'Community Collection 3', 'My Community Collection 3', [SampleThemesFixture::getTheme(3)->getId()])), 4 => $collectionService->createCollection(new CreateCollectionParameters(sprintf('community:%s', SampleCommunitiesFixture::getCommunity(4)->getId()), 'Community Collection 4', 'My Community Collection 4', [SampleThemesFixture::getTheme(4)->getId()])), 5 => $collectionService->createCollection(new CreateCollectionParameters(sprintf('community:%s', SampleCommunitiesFixture::getCommunity(5)->getId()), 'Community Collection 5', 'My Community Collection 5', [SampleThemesFixture::getTheme(5)->getId()]))]; }
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 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 = DemoProfileFixture::getProfile(); $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 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 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 testUploadImage200() { $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]]); }
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 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); }
public function test200() { $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()]]; $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']]]); $profileId = DemoProfileFixture::getProfile()->getId(); $collectionId = self::$currentResult->getContent()['entity']['id']; $this->requestGetProfile($profileId)->auth(DemoAccountFixture::getAccount()->getAPIKey())->execute()->expectStatusCode(200)->expectJSONContentType()->expect(function (array $jsonResponse) use($collectionId) { $collections = $jsonResponse['entity']['profile']['collections']; $this->assertTrue(is_array($collections)); $this->assertEquals(2, count($collections)); $this->assertEquals($collectionId, $collections[1]['collection_id']); }); }
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); }
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); } }]]]); }
public function testFeedbackCreateAnonymous200() { $profile = DemoProfileFixture::getProfile(); $json = ["profile_id" => $profile->getId(), "type_feedback" => FTCommonQuestion::INT_CODE, "description" => "Demo Feedback"]; $this->requestFeedbackCreate($json)->execute()->expectJSONContentType()->expectStatusCode(200)->expectJSONBody(['success' => true, 'entity' => ['type' => $json['type_feedback'], 'created_at' => $this->expectString(), 'profile' => ['has' => true, 'entity' => $profile->toJSON()], 'description' => $json['description']]]); }
public function testGetProfileBySID200() { $profile = DemoProfileFixture::getProfile(); $this->requestGetProfileBySID($profile->getSID())->execute()->expectStatusCode(200)->expectJSONContentType()->expectJSONBody(['success' => true, 'entity' => ['profile' => ['collections' => [0 => ['collection_id' => $this->expectId(), 'position' => 1]]], 'collections' => [0 => ['id' => $this->expectId(), 'sid' => $this->expectString(), 'owner_sid' => $this->expectString(), 'owner' => ['id' => $this->expectString(), 'type' => 'profile'], 'title' => $this->expectString(), 'description' => $this->expectString()]]]]); }
public function up(Application $app, EntityManager $em) { $profile1 = DemoProfileFixture::getProfile(); $params = [['type' => FTCommonQuestion::INT_CODE, 'read' => false, 'answer' => false], ['type' => FTCommonQuestion::INT_CODE, 'read' => false, 'answer' => false, 'anonymous' => '*****@*****.**'], ['type' => FTCommonQuestion::INT_CODE, 'read' => false, 'answer' => false], ['type' => FTCommonQuestion::INT_CODE, 'read' => false, 'answer' => false], ['type' => FTCommonQuestion::INT_CODE, 'read' => false, 'answer' => false], ['type' => FTThemeRequest::INT_CODE, 'read' => false, 'answer' => false], ['type' => FTSuggestion::INT_CODE, 'read' => false, 'answer' => false], ['type' => FTCommonQuestion::INT_CODE, 'read' => false, 'answer' => true], ['type' => FTCommonQuestion::INT_CODE, 'read' => true, 'answer' => true], ['type' => FTCommonQuestion::INT_CODE, 'read' => false, 'answer' => false]]; foreach ($params as $request) { $request = array_merge(['type' => FTCommonQuestion::INT_CODE, 'profile_id' => $profile1->getId(), 'anonymous' => null, 'description' => 'Demo Feedback', 'answer' => false, 'read' => false], $request); if ($request['anonymous']) { $request['profile_id'] = null; } $feedback = $this->service->createFeedback(new CreateFeedbackParameters($request['type'], $request['description'], $request['profile_id'], $request['anonymous'])); if ($request['answer']) { $this->service->answer(new CreateFeedbackResponseParameters('Demo Feedback Response', $feedback->getId())); if ($request['read']) { $this->service->markAsRead($feedback->getId()); } } } }