-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from signnow/1.x-test-coverage
Add tests
- Loading branch information
Showing
16 changed files
with
751 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
declare(strict_types = 1); | ||
|
||
namespace Tests\Fixtures\Entity; | ||
|
||
use JMS\Serializer\Annotation as Serializer; | ||
|
||
/** | ||
* Class StatusResponse | ||
* | ||
* @package Tests\Fixtures\Entity | ||
*/ | ||
class StatusResponse | ||
{ | ||
/** | ||
* @Serializer\Type("string") | ||
* @var string | ||
*/ | ||
private $status; | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getStatus(): string | ||
{ | ||
return $this->status; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
declare(strict_types = 1); | ||
|
||
namespace Tests\Fixtures\Entity; | ||
|
||
use SignNow\Rest\Entity\Entity; | ||
use SignNow\Rest\EntityManager\Annotation\HttpEntity; | ||
use SignNow\Rest\EntityManager\Annotation\GuzzleRequestBody; | ||
use SignNow\Rest\EntityManager\Annotation\ResponseType; | ||
use JMS\Serializer\Annotation as Serializer; | ||
|
||
/** | ||
* Class TemplateEntity | ||
* | ||
* @HttpEntity("template", idProperty="") | ||
* @GuzzleRequestBody("form_params") | ||
* @ResponseType("Tests\Fixtures\Entity\StatusResponse") | ||
* | ||
* @package Tests\Fixtures\Entity | ||
*/ | ||
class TemplateEntity extends Entity | ||
{ | ||
/** | ||
* @Serializer\Type("string") | ||
* @var string | ||
*/ | ||
private $id; | ||
|
||
/** | ||
* TemplateEntity constructor. | ||
* | ||
* @param string $id | ||
*/ | ||
public function __construct(string $id) | ||
{ | ||
$this->id = $id; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
declare(strict_types = 1); | ||
|
||
namespace Tests\Fixtures\Entity\Upload; | ||
|
||
use SignNow\Rest\Entity\Entity; | ||
use SignNow\Rest\EntityManager\Annotation\HttpEntity; | ||
use SignNow\Rest\EntityManager\Annotation\GuzzleRequestBody; | ||
use SignNow\Rest\EntityManager\Annotation\ResponseType; | ||
use JMS\Serializer\Annotation as Serializer; | ||
use SignNow\Rest\Service\Serializer\Type\FileLink; | ||
|
||
/** | ||
* Class FileLinkUpload | ||
* | ||
* @HttpEntity("document", idProperty="") | ||
* @GuzzleRequestBody("multipart") | ||
* @ResponseType("Tests\Fixtures\Entity\StatusResponse") | ||
* | ||
* @package Tests\Fixtures\Entity\Upload | ||
*/ | ||
class FileLinkUpload extends Entity | ||
{ | ||
/** | ||
* @Serializer\Type("SignNow\Rest\Service\Serializer\Type\FileLink") | ||
* @var FileLink | ||
*/ | ||
private $fileLink; | ||
|
||
/** | ||
* FileLinkUpload constructor. | ||
* | ||
* @param FileLink $fileLink | ||
*/ | ||
public function __construct(FileLink $fileLink) | ||
{ | ||
$this->fileLink = $fileLink; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
declare(strict_types = 1); | ||
|
||
namespace Tests\Fixtures\Entity\Upload; | ||
|
||
use SignNow\Rest\Entity\Entity; | ||
use SignNow\Rest\EntityManager\Annotation\HttpEntity; | ||
use SignNow\Rest\EntityManager\Annotation\GuzzleRequestBody; | ||
use SignNow\Rest\EntityManager\Annotation\ResponseType; | ||
use JMS\Serializer\Annotation as Serializer; | ||
use SignNow\Rest\Service\Serializer\Type\File; | ||
|
||
/** | ||
* Class FileUpload | ||
* | ||
* @HttpEntity("document", idProperty="") | ||
* @GuzzleRequestBody("multipart") | ||
* @ResponseType("Tests\Fixtures\Entity\StatusResponse") | ||
* | ||
* @package Tests\Fixtures\Entity\Upload | ||
*/ | ||
class FileUpload extends Entity | ||
{ | ||
/** | ||
* @Serializer\Type("SignNow\Rest\Service\Serializer\Type\File") | ||
* @var File | ||
*/ | ||
private $file; | ||
|
||
/** | ||
* FileUpload constructor. | ||
* | ||
* @param File $file | ||
*/ | ||
public function __construct(File $file) | ||
{ | ||
$this->file = $file; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
declare(strict_types = 1); | ||
|
||
namespace Tests\Fixtures\Entity\Upload; | ||
|
||
use SignNow\Rest\Entity\Entity; | ||
use SignNow\Rest\EntityManager\Annotation\HttpEntity; | ||
use SignNow\Rest\EntityManager\Annotation\GuzzleRequestBody; | ||
use SignNow\Rest\EntityManager\Annotation\ResponseType; | ||
use JMS\Serializer\Annotation as Serializer; | ||
use SplFileInfo; | ||
|
||
/** | ||
* Class SplFileInfoUpload | ||
* | ||
* @HttpEntity("document", idProperty="") | ||
* @GuzzleRequestBody("multipart") | ||
* @ResponseType("Tests\Fixtures\Entity\StatusResponse") | ||
* | ||
* @package Tests\Fixtures\Entity\Upload | ||
*/ | ||
class SplFileInfoUpload extends Entity | ||
{ | ||
/** | ||
* @Serializer\Type("SplFileInfo") | ||
* @var SplFileInfo | ||
*/ | ||
private $file; | ||
|
||
/** | ||
* @Serializer\Type("array") | ||
* @var array | ||
*/ | ||
private $tags; | ||
|
||
/** | ||
* SplFileInfoUpload constructor. | ||
* | ||
* @param SplFileInfo $file | ||
* @param array $tags | ||
*/ | ||
public function __construct(SplFileInfo $file, array $tags = []) | ||
{ | ||
$this->file = $file; | ||
$this->tags = $tags; | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
tests/unit/EntityManager/Annotation/GuzzleRequestBody/Multipart/ItemTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
declare(strict_types = 1); | ||
|
||
namespace Tests\Unit\EntityManager\Annotation\GuzzleRequestBody\Multipart; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use SignNow\Rest\EntityManager\Annotation\GuzzleRequestBody\Multipart\Item; | ||
|
||
/** | ||
* Class ItemTest | ||
* | ||
* @package Tests\Unit\EntityManager\Annotation\GuzzleRequestBody\Multipart | ||
*/ | ||
class ItemTest extends TestCase | ||
{ | ||
/** | ||
* @return void | ||
*/ | ||
public function testToArray(): void | ||
{ | ||
$item = new Item('name', 'content', ['header' => 'value'], 'filename'); | ||
$toArray = $item->toArray(); | ||
|
||
$this->assertArrayHasKey('name', $toArray); | ||
$this->assertArrayHasKey('contents', $toArray); | ||
$this->assertArrayHasKey('filename', $toArray); | ||
$this->assertArrayHasKey('headers', $toArray); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.