From 538c5054d66628a3477ef7b54d82f10c2085629e Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Fri, 16 May 2014 17:24:32 +0200 Subject: [PATCH] Fixed youtube uploads --- src/Models/Entities/PostEntity.php | 2 +- tests/Tests/JobTests/AddPostJobTest.php | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/Models/Entities/PostEntity.php b/src/Models/Entities/PostEntity.php index c9d29c10..a780c76b 100644 --- a/src/Models/Entities/PostEntity.php +++ b/src/Models/Entities/PostEntity.php @@ -57,7 +57,7 @@ final class PostEntity extends AbstractEntity implements IValidatable if (empty($this->getType())) throw new SimpleException('No post type detected'); - if (empty($this->tryGetWorkingFullPath())) + if (empty($this->tryGetWorkingFullPath()) and $this->type->toInteger() != PostType::Youtube) throw new SimpleException('No post content'); if (empty($this->getTags())) diff --git a/tests/Tests/JobTests/AddPostJobTest.php b/tests/Tests/JobTests/AddPostJobTest.php index 069f1eee..a1116af7 100644 --- a/tests/Tests/JobTests/AddPostJobTest.php +++ b/tests/Tests/JobTests/AddPostJobTest.php @@ -34,6 +34,30 @@ class AddPostJobTest extends AbstractTest $this->assert->isNotNull($post->getUploaderId()); } + public function testYoutube() + { + $this->prepare(); + + $this->grantAccess('addPost'); + $this->grantAccess('addPostTags'); + $this->grantAccess('addPostContent'); + + $this->login($this->userMocker->mockSingle()); + + $post = $this->assert->doesNotThrow(function() + { + return Api::run( + new AddPostJob(), + [ + JobArgs::ARG_NEW_TAG_NAMES => ['kamen', 'raider'], + JobArgs::ARG_NEW_POST_CONTENT_URL => 'http://www.youtube.com/watch?v=qWq_jydCUw4', + ]); + }); + + $this->assert->areEqual(PostType::Youtube, $post->getType()->toInteger()); + $this->assert->areEqual('qWq_jydCUw4', $post->getFileHash()); + } + public function testAnonymousUploads() { $this->prepare();