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 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()]]]]); }
public function testLeaveCommunity409() { $this->upFixture(new SamplePCBookmarksFixture()); $profile = DemoAccountFixture::getSecondAccount()->getCurrentProfile(); $community = SampleCommunitiesFixture::getCommunity(2); $this->requestLeave($profile->getId(), $community->getSID())->auth(DemoAccountFixture::getSecondAccount()->getAPIKey())->execute(); $this->requestLeave($profile->getId(), $community->getSID())->auth(DemoAccountFixture::getSecondAccount()->getAPIKey())->execute()->expectJSONContentType()->expectStatusCode(409)->expectJSONError(); }
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]]]]); }
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 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 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 testColor200() { $this->upFixture(new SampleCommunitiesFixture()); $account = DemoAccountFixture::getAccount(); $profile = DemoProfileFixture::getProfile(); $community = SampleCommunitiesFixture::getCommunity(1); $this->requestGetCommunityById($community->getId())->execute()->expectStatusCode(200)->expectJSONContentType()->expectJSONBody(['entity' => ['community' => ['backdrop' => ['type' => 'preset']]]]); $backdropJSON = $this->requestBackdropColor($community->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->requestGetCommunityById($community->getId())->execute()->expectStatusCode(200)->expectJSONContentType()->expectJSONBody(['entity' => ['community' => ['backdrop' => $backdropJSON]]]); }
public function testPreset200() { $this->upFixture(new SampleCommunitiesFixture()); $account = DemoAccountFixture::getAccount(); $profile = DemoProfileFixture::getProfile(); $community = SampleCommunitiesFixture::getCommunity(1); $this->requestGetCommunityById($community->getId())->execute()->expectStatusCode(200)->expectJSONContentType()->expectJSONBody(['entity' => ['community' => ['backdrop' => ['type' => 'preset']]]]); $backdropJSON = $this->requestBackdropPreset($community->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->requestGetCommunityById($community->getId())->execute()->expectStatusCode(200)->expectJSONContentType()->expectJSONBody(['entity' => ['community' => ['backdrop' => $backdropJSON]]]); }
public function testBackdropUploadTestSizes() { $this->upFixture(new SampleCommunitiesFixture()); $account = DemoAccountFixture::getAccount(); $profile = DemoProfileFixture::getProfile(); $community = SampleCommunitiesFixture::getCommunity(1); $this->requestBackdropUpload($community->getId(), __DIR__ . '/../Resources/grid399x399.png', 'ffffff')->auth($account->getAPIKey())->execute()->expectStatusCode(409)->expectJSONContentType()->expectJSONBody(['success' => false, 'error' => $this->expectString()]); $this->requestBackdropUpload($community->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($community->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($community->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($community->getId(), __DIR__ . '/../Resources/grid2049x2049.png', 'ffffff')->auth($account->getAPIKey())->execute()->expectStatusCode(409)->expectJSONContentType()->expectJSONBody(['success' => false, 'error' => $this->expectString()]); }
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 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 testCommunityGetById() { $this->upFixture(new SampleCommunitiesFixture()); $sampleCommunity = SampleCommunitiesFixture::getCommunity(2); $this->requestGetCommunityById($sampleCommunity->getId())->execute()->expectStatusCode(200)->expectJSONContentType()->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' => $sampleCommunity->getTitle(), 'description' => $sampleCommunity->getDescription(), 'theme' => ['has' => true, 'id' => $sampleCommunity->getTheme()->getId()], 'image' => $this->expectImageCollection()]]]); }
public function testUnsubscribeCollectionSuccess200() { $community = SampleCommunitiesFixture::getCommunity(1); $account = DemoAccountFixture::getAccount(); $this->requestUnSubscribeCommunity($community->getId())->auth($account->getAPIKey())->execute()->expectStatusCode(200)->expectJSONContentType()->expectJSONBody(['success' => true]); }
public function testSubscribeCommunityNotAuth403() { $community = SampleCommunitiesFixture::getCommunity(1); $this->requestSubscribeCommunity($community->getId())->execute()->expectStatusCode(403); }
public function testUploadImageTooBig() { $this->upFixture(new SampleCommunitiesFixture()); $sampleCommunity = SampleCommunitiesFixture::getCommunity(2); $this->requestUploadImage($sampleCommunity->getId(), new Point(0, 0), new Point(9999, 9999))->auth(DemoAccountFixture::getAccount()->getAPIKey())->execute()->expectJSONContentType()->expectStatusCode(422)->expectJSONError(); }
public function testDeleteCommunityImage200() { $this->upFixture(new SampleCommunitiesFixture()); $this->requestDeleteImage(SampleCommunitiesFixture::getCommunity(1)->getId())->auth(DemoAccountFixture::getAccount()->getAPIKey())->execute()->expectStatusCode(200)->expectJSONContentType()->expectJSONBody(['success' => true, 'image' => $this->expectImageCollection()])->expectJSONBody(['image' => ['is_auto_generated' => true]]); }
public function testIsFeatureActivated200() { $community = SampleCommunitiesFixture::getCommunity(1); $communityId = $community->getId(); $this->activateFeature($communityId, CollectionsFeature::getCode()); $this->areFeaturesActivated($communityId, [CollectionsFeature::getCode() => true, BoardsFeature::getCode() => false, ChatFeature::getCode() => false]); $this->activateFeature($communityId, ChatFeature::getCode()); $this->areFeaturesActivated($communityId, [CollectionsFeature::getCode() => true, BoardsFeature::getCode() => false, ChatFeature::getCode() => true]); $this->activateFeature($communityId, BoardsFeature::getCode()); $this->areFeaturesActivated($communityId, [CollectionsFeature::getCode() => true, BoardsFeature::getCode() => true, ChatFeature::getCode() => true]); $this->deactivateFeature($communityId, CollectionsFeature::getCode()); $this->areFeaturesActivated($communityId, [CollectionsFeature::getCode() => false, BoardsFeature::getCode() => true, ChatFeature::getCode() => true]); $this->deactivateFeature($communityId, BoardsFeature::getCode()); $this->deactivateFeature($communityId, ChatFeature::getCode()); $this->areFeaturesActivated($communityId, [CollectionsFeature::getCode() => false, BoardsFeature::getCode() => false, ChatFeature::getCode() => false]); $this->activateFeature($communityId, CollectionsFeature::getCode()); $this->activateFeature($communityId, BoardsFeature::getCode()); $this->activateFeature($communityId, ChatFeature::getCode()); $this->areFeaturesActivated($communityId, [CollectionsFeature::getCode() => true, BoardsFeature::getCode() => true, ChatFeature::getCode() => true]); $this->deactivateFeature($communityId, CollectionsFeature::getCode()); $this->deactivateFeature($communityId, BoardsFeature::getCode()); $this->deactivateFeature($communityId, ChatFeature::getCode()); $this->areFeaturesActivated($communityId, [CollectionsFeature::getCode() => false, BoardsFeature::getCode() => false, ChatFeature::getCode() => false]); }