Commit cba0d53b authored by Marcelo Rivera's avatar Marcelo Rivera

(fix): spec tests

parent 24d1a927
No related merge requests found
Pipeline #93550785 failed with stages
in 6 minutes and 20 seconds
......@@ -33,6 +33,7 @@ class ManagerSpec extends ObjectBehavior
{
$activity = new Activity();
$activity->set('entity_guid', 123);
$activity->set('access_id', ACCESS_PRIVATE);
$this->config->get('cdn_url')
->willReturn('https://minds.dev/');
$uri = 'https://minds.dev/fs/v1/thumbnail/123/xlarge';
......@@ -42,10 +43,22 @@ class ManagerSpec extends ObjectBehavior
->shouldBe('signed url will be here');
}
public function it_should_return_unsigned_public_asset_uri()
{
$activity = new Activity();
$activity->set('entity_guid', 123);
$activity->set('access_id', ACCESS_PUBLIC);
$this->config->get('cdn_url')
->willReturn('https://minds.dev/');
$this->getPublicAssetUri($activity)
->shouldBe('https://minds.dev/fs/v1/thumbnail/123/xlarge');
}
public function it_should_return_public_asset_uri_for_image()
{
$entity = new Image();
$entity->set('guid', 123);
$entity->set('access_id', ACCESS_PRIVATE);
$this->config->get('cdn_url')
->willReturn('https://minds.dev/');
$uri = 'https://minds.dev/fs/v1/thumbnail/123/xlarge';
......@@ -55,10 +68,21 @@ class ManagerSpec extends ObjectBehavior
->shouldBe('signed url will be here');
}
public function it_should_return_an_unsigned_url_for_an_image() {
$entity = new Image();
$entity->set('guid', 123);
$entity->set('access_id', ACCESS_PUBLIC);
$this->config->get('cdn_url')
->willReturn('https://minds.dev/');
$this->getPublicAssetUri($entity)
->shouldBe('https://minds.dev/fs/v1/thumbnail/123/xlarge');
}
public function it_should_return_public_asset_uri_for_video()
{
$entity = new Video();
$entity->set('guid', 123);
$entity->set('access_id', ACCESS_PRIVATE);
$this->config->get('cdn_url')
->willReturn('https://minds.dev/');
$uri = 'https://minds.dev/fs/v1/thumbnail/123/xlarge';
......@@ -68,6 +92,19 @@ class ManagerSpec extends ObjectBehavior
->shouldBe('signed url will be here');
}
public function it_should_return_unsigned_public_asset_uri_for_video()
{
$entity = new Video();
$entity->set('guid', 123);
$entity->set('access_id', ACCESS_PUBLIC);
$this->config->get('cdn_url')
->willReturn('https://minds.dev/');
$uri = 'https://minds.dev/fs/v1/thumbnail/123/xlarge';
$this->getPublicAssetUri($entity)
->shouldBe('https://minds.dev/fs/v1/thumbnail/123/xlarge');
}
public function it_should_return_public_asset_uri_for_comment()
{
$entity = new Comment();
......@@ -80,4 +117,15 @@ class ManagerSpec extends ObjectBehavior
$this->getPublicAssetUri($entity)
->shouldBe('signed url will be here');
}
public function it_should_return_unsigned_public_asset_uri_for_comment()
{
$entity = new Comment();
$entity->setAttachment('attachment_guid', '123');
$entity->access_id = ACCESS_PUBLIC;
$this->config->get('cdn_url')
->willReturn('https://minds.dev/');
$this->getPublicAssetUri($entity)
->shouldBe('https://minds.dev/fs/v1/thumbnail/123/xlarge');
}
}
......@@ -27,7 +27,7 @@ class ManagerSpec extends ObjectBehavior
$this->shouldHaveType(Manager::class);
}
public function it_should_get_a_720p_video(RequestInterface $request, \Aws\CommandInterface $cmd)
public function it_should_get_a_signed_720p_video_url(RequestInterface $request, \Aws\CommandInterface $cmd)
{
$this->config->get('transcoder')
->willReturn([
......@@ -39,22 +39,60 @@ class ManagerSpec extends ObjectBehavior
'useRoles' => true,
]);
$this->config->get('cinemr_url')
->willReturn('https://url.com/cinemr');
$this->s3->getCommand('GetObject', [
'Bucket' => 'cinemr',
'Key' => 'dir/123/720.mp4'
])
->shouldBeCalled()
->willReturn($cmd);
$request->getUri()
->willReturn('s3-signed-url-here');
$this->s3->createPresignedRequest(Argument::any(), Argument::any())
->willReturn($request);
$video = new Video();
$video->set('cinemr_guid', 123);
$video->set('access_id', ACCESS_PRIVATE);
$this->getPublicAssetUri($video, '720.mp4')
->shouldBe('s3-signed-url-here');
}
public function it_should_get_an_unsigned_720p_video_url(RequestInterface $request, \Aws\CommandInterface $cmd)
{
$this->config->get('transcoder')
->willReturn([
'dir' => 'dir',
]);
$this->config->get('aws')
->willReturn([
'region' => 'us-east-1',
'useRoles' => true,
]);
$this->config->get('cinemr_url')
->willReturn('https://url.com/cinemr');
$this->s3->getCommand('GetObject', [
'Bucket' => 'cinemr',
'Key' => 'dir/123/720.mp4'
])
->shouldBeCalled()
->willReturn($cmd);
$request->getUri()
->willReturn('s3-signed-url-here');
$this->s3->createPresignedRequest(Argument::any(), Argument::any())
->willReturn($request);
$video = new Video();
$video->set('cinemr_guid', 123);
$this->getPublicAssetUri($video, '720.mp4')
->shouldBe('https://url.com/cinemr123/720.mp4');
}
}
Please register or to comment