Пример #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()]);
 }
Пример #2
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 testUnSubscribeCollectionUnAuth403()
 {
     $collections = SampleCollectionsFixture::getCommunityCollections();
     /** @var Collection $collection */
     $collection = array_shift($collections);
     $this->requestUnSubscribeCollection($collection->getId())->execute()->expectStatusCode(403);
 }
Пример #4
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', []));
     }
 }
 public function testNone200()
 {
     $this->upFixture(new SampleCollectionsFixture());
     $account = DemoAccountFixture::getAccount();
     $profile = DemoProfileFixture::getProfile();
     $collection = SampleCollectionsFixture::getProfileCollection(1);
     $this->requestBackdropNone($collection->getId())->auth($account->getAPIKey())->execute()->expectStatusCode(200)->expectJSONContentType()->expectJSONBody(['backdrop' => ['type' => 'none']]);
     $this->requestGetById($collection->getId())->execute()->expectStatusCode(200)->expectJSONContentType()->expectJSONBody(['entity' => ['backdrop' => ['type' => 'none']]]);
 }
 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 testColor200()
 {
     $this->upFixture(new SampleCollectionsFixture());
     $account = DemoAccountFixture::getAccount();
     $profile = DemoProfileFixture::getProfile();
     $collection = SampleCollectionsFixture::getProfileCollection(1);
     $this->requestGetById($collection->getId())->execute()->expectStatusCode(200)->expectJSONContentType()->expectJSONBody(['entity' => ['backdrop' => ['type' => 'preset']]]);
     $backdropJSON = $this->requestBackdropColor($collection->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->requestGetById($collection->getId())->execute()->expectStatusCode(200)->expectJSONContentType()->expectJSONBody(['entity' => ['backdrop' => $backdropJSON]]);
 }
 public function testPreset200()
 {
     $this->upFixture(new SampleCollectionsFixture());
     $account = DemoAccountFixture::getAccount();
     $profile = DemoProfileFixture::getProfile();
     $collection = SampleCollectionsFixture::getProfileCollection(1);
     $this->requestGetById($collection->getId())->execute()->expectStatusCode(200)->expectJSONContentType()->expectJSONBody(['entity' => ['backdrop' => ['type' => 'preset']]]);
     $backdropJSON = $this->requestBackdropPreset($collection->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->requestGetById($collection->getId())->execute()->expectStatusCode(200)->expectJSONContentType()->expectJSONBody(['entity' => ['backdrop' => $backdropJSON]]);
 }
 public function testBackdropUploadTestSizes()
 {
     $this->upFixture(new SampleCollectionsFixture());
     $account = DemoAccountFixture::getAccount();
     $profile = DemoProfileFixture::getProfile();
     $collection = SampleCollectionsFixture::getProfileCollection(1);
     $this->requestBackdropUpload($collection->getId(), __DIR__ . '/../Resources/grid399x399.png', 'ffffff')->auth($account->getAPIKey())->execute()->expectStatusCode(409)->expectJSONContentType()->expectJSONBody(['success' => false, 'error' => $this->expectString()]);
     $this->requestBackdropUpload($collection->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($collection->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($collection->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($collection->getId(), __DIR__ . '/../Resources/grid2049x2049.png', 'ffffff')->auth($account->getAPIKey())->execute()->expectStatusCode(409)->expectJSONContentType()->expectJSONBody(['success' => false, 'error' => $this->expectString()]);
 }
Пример #10
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()]]]]]]);
 }
Пример #11
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);
 }
 public function test200()
 {
     $this->upFixture(new SampleCollectionsFixture());
     $collectionToDelete = SampleCollectionsFixture::getCommunityCollection(1);
     $collectionId = $collectionToDelete->getId();
     list(, $communityId) = explode(':', $collectionToDelete->getOwnerSID());
     $this->requestGetCommunity($communityId)->execute()->expectStatusCode(200)->expectJSONContentType()->expect(function (array $jsonResponse) use($collectionId) {
         $collectionIds = array_map(function (array $input) {
             return $input['collection_id'];
         }, $jsonResponse['entity']['community']['collections']);
         $this->assertTrue(in_array($collectionId, $collectionIds));
     });
     $this->requestDeleteCollection($collectionToDelete->getId())->auth(DemoAccountFixture::getAccount()->getAPIKey())->execute()->expectStatusCode(200)->expectJSONContentType()->expectJSONBody(['success' => true]);
     $this->requestGetCommunity($communityId)->execute()->expectStatusCode(200)->expectJSONContentType()->expect(function (array $jsonResponse) use($collectionId) {
         $collectionIds = array_map(function (array $input) {
             return $input['collection_id'];
         }, $jsonResponse['entity']['community']['collections']);
         $this->assertFalse(in_array($collectionId, $collectionIds));
     });
 }