/**
  * @test
  */
 public function it_filters_out_access_token_from_post()
 {
     $SUT = new CreatePostCommand($entry = ["access_token" => "test"], $files = [], $token = "");
     $expected = [];
     $result = $SUT->getEntry();
     $this->assertEquals($expected, $result);
 }
示例#2
0
 public function handle(CreatePostCommand $command)
 {
     try {
         $response = $this->accessTokenRepository->getTokenFromAuthCode($command->getAccessToken());
     } catch (\Exception $e) {
         $message = sprintf("Invalid access token [%s]", $command->getAccessToken());
         return new Unauthorized(["message" => $message]);
     }
     try {
         $post = new NewPost($command->getEntry(), $command->getFiles());
         $this->postRepository->save($post, $command->getFiles());
         return new OK(["items" => [$post]]);
     } catch (\Exception $e) {
         $message = sprintf("Failed to save new post [%s]", $e->getMessage());
         return new ServerError(["message" => $message]);
     }
 }