-
Notifications
You must be signed in to change notification settings - Fork 198
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 #303 from HubSpot/review/pipeline
update Crm Pipelines + tests
- Loading branch information
Showing
5 changed files
with
151 additions
and
186 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
<?php | ||
|
||
namespace SevenShores\Hubspot\Tests\Integration\Abstraction; | ||
|
||
use SevenShores\Hubspot\Resources\CrmPipelines; | ||
|
||
/** | ||
* @internal | ||
* @coversNothing | ||
*/ | ||
class CrmPipelinesTestCase extends EntityTestCase | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
protected $type = 'deals'; | ||
|
||
/** | ||
* @var SevenShores\Hubspot\Resources\CrmPipelines | ||
*/ | ||
protected $resource; | ||
|
||
/** | ||
* @var SevenShores\Hubspot\Resources\CrmPipelines::class | ||
*/ | ||
protected $resourceClass = CrmPipelines::class; | ||
|
||
/** @test */ | ||
public function getAllPipelinesTest() | ||
{ | ||
$response = $this->resource->all($this->type); | ||
|
||
$this->assertEquals(200, $response->getStatusCode()); | ||
} | ||
|
||
/** @test */ | ||
public function getAllPipelinesIncludingDeleted() | ||
{ | ||
$response = $this->resource->all($this->type, ['includeInactive' => 'INCLUDE_DELETED']); | ||
|
||
$this->assertEquals(200, $response->getStatusCode()); | ||
} | ||
|
||
/** @test */ | ||
public function createPipeline() | ||
{ | ||
$this->assertEquals(200, $this->entity->getStatusCode()); | ||
} | ||
|
||
/** @test */ | ||
public function updatePipeline() | ||
{ | ||
$response = $this->resource->update( | ||
$this->type, | ||
$this->entity->pipelineId, | ||
$this->getData('Updated '.$this->type.' Pipeline') | ||
); | ||
|
||
$this->assertEquals(200, $response->getStatusCode()); | ||
} | ||
|
||
/** @test */ | ||
public function deletePipeline() | ||
{ | ||
$response = $this->deleteEntity(); | ||
|
||
$this->assertEquals(204, $response->getStatusCode()); | ||
|
||
$this->entity = null; | ||
} | ||
|
||
protected function createEntity() | ||
{ | ||
return $this->resource->create($this->type, $this->getData()); | ||
} | ||
|
||
protected function deleteEntity() | ||
{ | ||
return $this->resource->delete($this->type, $this->entity->pipelineId); | ||
} | ||
|
||
protected function getData(string $label = null) | ||
{ | ||
if (is_null($label)) { | ||
$label = 'Demo '.$this->type.' Pipeline'; | ||
} | ||
|
||
return [ | ||
'label' => $label.' '.uniqid(), | ||
'displayOrder' => 1, | ||
'active' => true, | ||
'stages' => [ | ||
[ | ||
'label' => 'Demo Stage', | ||
'displayOrder' => 1, | ||
'metadata' => [ | ||
'probability' => 0.5, | ||
], | ||
], | ||
], | ||
]; | ||
} | ||
} |
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,13 @@ | ||
<?php | ||
|
||
namespace SevenShores\Hubspot\Tests\integration\Resources; | ||
|
||
use SevenShores\Hubspot\Tests\Integration\Abstraction\CrmPipelinesTestCase; | ||
|
||
/** | ||
* @internal | ||
* @coversNothing | ||
*/ | ||
class CrmPipelinesDealsTest extends CrmPipelinesTestCase | ||
{ | ||
} |
This file was deleted.
Oops, something went wrong.
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,17 @@ | ||
<?php | ||
|
||
namespace SevenShores\Hubspot\Tests\integration\Resources; | ||
|
||
use SevenShores\Hubspot\Tests\Integration\Abstraction\CrmPipelinesTestCase; | ||
|
||
/** | ||
* @internal | ||
* @coversNothing | ||
*/ | ||
class CrmPipelinesTicketsTest extends CrmPipelinesTestCase | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
protected $type = 'tickets'; | ||
} |