-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add PropertyMetadata description (#365)
- Loading branch information
Showing
28 changed files
with
102 additions
and
9 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
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
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
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
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
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,63 @@ | ||
<?php | ||
|
||
namespace Notion\Test\Unit\Databases\Properties; | ||
|
||
use Notion\Databases\Properties\PropertyMetadata; | ||
use Notion\Databases\Properties\PropertyType; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class PropertyMetadataTest extends TestCase | ||
{ | ||
public function test_create(): void | ||
{ | ||
$metadata = PropertyMetadata::create("abc", "Dummy prop name", PropertyType::CreatedBy, "foo bar"); | ||
|
||
$this->assertEquals("abc", $metadata->id); | ||
$this->assertEquals("Dummy prop name", $metadata->name); | ||
$this->assertEquals(PropertyType::CreatedBy, $metadata->type); | ||
$this->assertEquals("foo bar", $metadata->description); | ||
} | ||
|
||
public function test_from_array(): void | ||
{ | ||
$array = [ | ||
"id" => "abc", | ||
"name" => "dummy", | ||
"type" => "created_by", | ||
"created_by" => new \stdClass(), | ||
"description" => "foo bar", | ||
]; | ||
$metadata = PropertyMetadata::fromArray($array); | ||
|
||
$this->assertEquals($array["id"], $metadata->id); | ||
$this->assertEquals($array["name"], $metadata->name); | ||
$this->assertEquals(PropertyType::CreatedBy, $metadata->type); | ||
$this->assertEquals($array["description"], $metadata->description); | ||
|
||
$toArray = $metadata->toArray(); | ||
|
||
$this->assertEqualsCanonicalizing(['id', 'name', 'type', 'description'], array_keys($toArray)); | ||
} | ||
|
||
public function test_from_array_without_description(): void | ||
{ | ||
$array = [ | ||
"id" => "abc", | ||
"name" => "dummy", | ||
"type" => "created_by", | ||
"created_by" => new \stdClass(), | ||
]; | ||
|
||
$metadata = PropertyMetadata::fromArray($array); | ||
|
||
$this->assertEquals($array["id"], $metadata->id); | ||
$this->assertEquals($array["name"], $metadata->name); | ||
$this->assertEquals(PropertyType::CreatedBy, $metadata->type); | ||
$this->assertNull($metadata->description); | ||
|
||
$toArray = $metadata->toArray(); | ||
|
||
// When there is no description, its key won't show up | ||
$this->assertEqualsCanonicalizing(['id', 'name', 'type'], array_keys($toArray)); | ||
} | ||
} |