/** * @test */ public function should_upload_an_article_and_respond_with_article_instance() { $responseMock = $this->createResponseMock(200, __DIR__ . '/../../fixtures/articles/uploaded.json'); $apiClient = $this->createTestApiClient($responseMock); $article = new UploadArticle(); $article->setCollectionId(uniqid()); $article->setName(uniqid('Uploaded Article ')); $article->setFile(__DIR__ . '/../../fixtures/articles/article.html'); $uploaded = $apiClient->uploadArticle($article, true); $this->assertInstanceOf(Article::class, $uploaded); }
<?php use HelpScoutDocs\DocsApiClient; use HelpScoutDocs\Models\UploadArticle; require_once __DIR__ . '/../vendor/autoload.php'; $docsClient = new DocsApiClient(); $docsClient->setKey('API_KEY'); $upload = new UploadArticle(); $upload->setCollectionId('COLLECTION_ID'); $upload->setName(uniqid('Uploaded Article ')); $upload->setFile('REAL_PATH_TO_FILE'); $article = $docsClient->uploadArticle($upload, true);