public function testCreateCommunity403()
 {
     $theme = SampleThemesFixture::getTheme(1);
     /** @var Theme $theme */
     $json = ['title' => 'Community 1', 'description' => 'My Community 1', 'theme_id' => $theme->getId()];
     $this->requestCreateCommunity($json)->execute()->expectJSONContentType()->expectStatusCode(403)->expectJSONError();
 }
 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]);
 }
Example #3
0
 public function test200()
 {
     $this->upFixture(new SampleCollectionsFixture());
     $collection = SampleCollectionsFixture::getCommunityCollection(1);
     $json = ['title' => '* my edited title', 'description' => '* my edited description', 'theme_ids' => [SampleThemesFixture::getTheme(3)->getId(), SampleThemesFixture::getTheme(5)->getId()]];
     $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)
 {
     $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()]))];
 }
Example #5
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()]]]]);
 }
 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 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()
 {
     $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 testDeleteTheme200()
 {
     $this->requestDeleteTheme(SampleThemesFixture::getTheme(1)->getId())->auth(DemoAccountFixture::getAccount()->getAPIKey())->execute()->expectJSONContentType()->expectStatusCode(200)->expectJSONBody(['success' => true]);
 }
 public function testThemeUpdate200()
 {
     $ThemeFixture = SampleThemesFixture::getTheme(1);
     $json = ['title' => 'Theme 1', 'description' => 'My Demo Theme Description', 'parent_id' => 0];
     $this->requestPostUpdateTheme($ThemeFixture->getId(), $json)->auth(DemoAccountFixture::getAccount()->getAPIKey())->execute()->expectJSONContentType()->expectStatusCode(200)->expectJSONBody(['success' => true]);
 }
 public function up(Application $app, EntityManager $em)
 {
     $communityService = $app->getContainer()->get(CommunityService::class);
     /** @var CommunityService $communityService */
     self::$communities = [1 => $communityService->createCommunity(new CreateCommunityParameters('Community 1', 'My Community 1', SampleThemesFixture::getTheme(1)->getId())), 2 => $communityService->createCommunity(new CreateCommunityParameters('Community 2', 'My Community 2', SampleThemesFixture::getTheme(2)->getId())), 3 => $communityService->createCommunity(new CreateCommunityParameters('Community 3', 'My Community 3', SampleThemesFixture::getTheme(3)->getId())), 4 => $communityService->createCommunity(new CreateCommunityParameters('Community 4', 'My Community 4', SampleThemesFixture::getTheme(4)->getId())), 5 => $communityService->createCommunity(new CreateCommunityParameters('Community 5', 'My Community 5', SampleThemesFixture::getTheme(5)->getId()))];
 }
 public function testUnSubscribeThemeNotAuth403()
 {
     $theme = SampleThemesFixture::getTheme(1);
     $this->requestUnSubscribeTheme($theme->getId())->execute()->expectStatusCode(403);
 }
 public function testGetTheme200()
 {
     $fixtureTheme = SampleThemesFixture::getTheme(2);
     $this->requestGetTheme($fixtureTheme->getId())->auth(DemoAccountFixture::getAccount()->getAPIKey())->execute()->expectJSONContentType()->expectStatusCode(200)->expectJSONBody(['success' => true, 'entity' => ['id' => $fixtureTheme->getId(), 'title' => $fixtureTheme->getTitle(), 'parent_id' => null, 'description' => $fixtureTheme->getDescription()]]);
 }