-
Notifications
You must be signed in to change notification settings - Fork 173
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 #214 from podio-community/213-fix-exceptions-on-save
- Loading branch information
Showing
6 changed files
with
78 additions
and
3 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
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,29 @@ | ||
<?php | ||
|
||
namespace Podio\Tests; | ||
|
||
require __DIR__ . '/../vendor/autoload.php'; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use PodioItem; | ||
use PodioItemFieldCollection; | ||
|
||
class PodioItemFieldTest extends TestCase | ||
{ | ||
public function test_save_should_throw_error_if_relationship_to_item_missing(): void | ||
{ | ||
$this->expectException('PodioMissingRelationshipError'); | ||
$itemField = new \PodioItemField(); | ||
$itemField->save(); | ||
} | ||
|
||
public function test_save_should_throw_error_if_external_id_missing(): void | ||
{ | ||
$this->expectException('PodioDataIntegrityError'); | ||
$itemField = new \PodioItemField(); | ||
// assure relationship to item is present: | ||
new PodioItem(['fields' => new PodioItemFieldCollection([$itemField])]); | ||
|
||
$itemField->save(); | ||
} | ||
} |
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 | ||
|
||
namespace Podio\Tests; | ||
|
||
require __DIR__ . '/../vendor/autoload.php'; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use PodioApp; | ||
use PodioItem; | ||
use PodioItemFieldCollection; | ||
use PodioTextItemField; | ||
|
||
class PodioItemTest extends TestCase | ||
{ | ||
public function test_create_item(): void | ||
{ | ||
$item = new PodioItem([ | ||
'app' => new PodioApp(1234), | ||
'fields' => new PodioItemFieldCollection([ | ||
new PodioTextItemField(["external_id" => "title", "values" => "TEST"]), | ||
]) | ||
]); | ||
|
||
$this->assertEquals(1234, $item->app->id); | ||
} | ||
|
||
|
||
public function test_save_should_throw_error_if_app_id_missing(): void | ||
{ | ||
$this->expectException('PodioMissingRelationshipError'); | ||
$item = new PodioItem([ | ||
'fields' => new PodioItemFieldCollection([ | ||
new PodioTextItemField(["external_id" => "title", "values" => "TEST"]), | ||
]) | ||
]); | ||
$item->save(); | ||
} | ||
} |