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()]); }
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()]]]]]]); }
public function test200() { $this->upFixture(new SampleCollectionsFixture()); $collectionToDelete = SampleCollectionsFixture::getProfileCollection(1); $collectionId = $collectionToDelete->getId(); list(, $profileId) = explode(':', $collectionToDelete->getOwnerSID()); $this->requestGetProfile($profileId)->execute()->expectStatusCode(200)->expectJSONContentType()->expect(function (array $jsonResponse) use($collectionId) { $collectionIds = array_map(function (array $input) { return $input['collection_id']; }, $jsonResponse['entity']['profile']['collections']); $this->assertTrue(in_array($collectionId, $collectionIds)); }); $this->requestDeleteCollection($collectionToDelete->getId())->auth(DemoAccountFixture::getAccount()->getAPIKey())->execute()->expectStatusCode(200)->expectJSONContentType()->expectJSONBody(['success' => true]); $this->requestGetProfile($profileId)->execute()->expectStatusCode(200)->expectJSONContentType()->expect(function (array $jsonResponse) use($collectionId) { $collectionIds = array_map(function (array $input) { return $input['collection_id']; }, $jsonResponse['entity']['profile']['collections']); $this->assertFalse(in_array($collectionId, $collectionIds)); }); }