Skip to content

Commit

Permalink
Add BlockFactory to unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mariosimao committed Oct 21, 2021
1 parent 50e012b commit e44ab0b
Show file tree
Hide file tree
Showing 11 changed files with 32 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tests/Unit/Blocks/BulletedListItemTest.php
Expand Up @@ -2,6 +2,7 @@

namespace Notion\Test\Unit\Blocks;

use Notion\Blocks\BlockFactory;
use Notion\Blocks\BulletedListItem;
use Notion\Common\Date;
use Notion\Common\RichText;
Expand Down Expand Up @@ -81,6 +82,8 @@ public function test_create_from_array(): void
$this->assertEmpty($item->children());
$this->assertEquals("Notion items rock!", $item->toString());
$this->assertFalse($item->block()->archived());

$this->assertEquals($item, BlockFactory::fromArray($array));
}

public function test_error_on_wrong_type(): void
Expand Down
3 changes: 3 additions & 0 deletions tests/Unit/Blocks/CalloutTest.php
Expand Up @@ -2,6 +2,7 @@

namespace Notion\Test\Unit\Blocks;

use Notion\Blocks\BlockFactory;
use Notion\Blocks\Callout;
use Notion\Common\Date;
use Notion\Common\Emoji;
Expand Down Expand Up @@ -87,6 +88,8 @@ public function test_create_from_array_with_emoji_icon(): void
$this->assertEquals("Notion callouts rock!", $callout->toString());
$this->assertEquals("☀️", $callout->icon()->emoji());
$this->assertFalse($callout->block()->archived());

$this->assertEquals($callout, BlockFactory::fromArray($array));
}

public function test_create_from_array_with_icon_file(): void
Expand Down
2 changes: 2 additions & 0 deletions tests/Unit/Blocks/CodeTest.php
Expand Up @@ -2,6 +2,7 @@

namespace Notion\Test\Unit\Blocks;

use Notion\Blocks\BlockFactory;
use Notion\Blocks\Code;
use Notion\Common\Date;
use Notion\Common\RichText;
Expand Down Expand Up @@ -55,6 +56,7 @@ public function test_create_from_array(): void

$this->assertCount(1, $code->text());
$this->assertEquals("<?php\necho 'Hello World!';", $code->toString());
$this->assertEquals($code, BlockFactory::fromArray($array));
}

public function test_error_on_wrong_type(): void
Expand Down
3 changes: 3 additions & 0 deletions tests/Unit/Blocks/Heading1Test.php
Expand Up @@ -2,6 +2,7 @@

namespace Notion\Test\Unit\Blocks;

use Notion\Blocks\BlockFactory;
use Notion\Blocks\Heading1;
use Notion\Common\Date;
use Notion\Common\RichText;
Expand Down Expand Up @@ -79,6 +80,8 @@ public function test_create_from_array(): void
$this->assertCount(2, $heading->text());
$this->assertEquals("Notion headings rock!", $heading->toString());
$this->assertFalse($heading->block()->archived());

$this->assertEquals($heading, BlockFactory::fromArray($array));
}

public function test_error_on_wrong_type(): void
Expand Down
3 changes: 3 additions & 0 deletions tests/Unit/Blocks/Heading2Test.php
Expand Up @@ -2,6 +2,7 @@

namespace Notion\Test\Unit\Blocks;

use Notion\Blocks\BlockFactory;
use Notion\Blocks\Heading2;
use Notion\Common\Date;
use Notion\Common\RichText;
Expand Down Expand Up @@ -79,6 +80,8 @@ public function test_create_from_array(): void
$this->assertCount(2, $heading->text());
$this->assertEquals("Notion headings rock!", $heading->toString());
$this->assertFalse($heading->block()->archived());

$this->assertEquals($heading, BlockFactory::fromArray($array));
}

public function test_error_on_wrong_type(): void
Expand Down
3 changes: 3 additions & 0 deletions tests/Unit/Blocks/Heading3Test.php
Expand Up @@ -2,6 +2,7 @@

namespace Notion\Test\Unit\Blocks;

use Notion\Blocks\BlockFactory;
use Notion\Blocks\Heading3;
use Notion\Common\Date;
use Notion\Common\RichText;
Expand Down Expand Up @@ -79,6 +80,8 @@ public function test_create_from_array(): void
$this->assertCount(2, $heading->text());
$this->assertEquals("Notion headings rock!", $heading->toString());
$this->assertFalse($heading->block()->archived());

$this->assertEquals($heading, BlockFactory::fromArray($array));
}

public function test_error_on_wrong_type(): void
Expand Down
3 changes: 3 additions & 0 deletions tests/Unit/Blocks/NumberedListItemTest.php
Expand Up @@ -2,6 +2,7 @@

namespace Notion\Test\Unit\Blocks;

use Notion\Blocks\BlockFactory;
use Notion\Blocks\NumberedListItem;
use Notion\Common\Date;
use Notion\Common\RichText;
Expand Down Expand Up @@ -81,6 +82,8 @@ public function test_create_from_array(): void
$this->assertEmpty($item->children());
$this->assertEquals("Notion items rock!", $item->toString());
$this->assertFalse($item->block()->archived());

$this->assertEquals($item, BlockFactory::fromArray($array));
}

public function test_error_on_wrong_type(): void
Expand Down
3 changes: 3 additions & 0 deletions tests/Unit/Blocks/ParagraphTest.php
Expand Up @@ -2,6 +2,7 @@

namespace Notion\Test\Unit\Blocks;

use Notion\Blocks\BlockFactory;
use Notion\Blocks\Paragraph;
use Notion\Common\Date;
use Notion\Common\RichText;
Expand Down Expand Up @@ -81,6 +82,8 @@ public function test_create_from_array(): void
$this->assertEmpty($paragraph->children());
$this->assertEquals("Notion paragraphs rock!", $paragraph->toString());
$this->assertFalse($paragraph->block()->archived());

$this->assertEquals($paragraph, BlockFactory::fromArray($array));
}

public function test_error_on_wrong_type(): void
Expand Down
3 changes: 3 additions & 0 deletions tests/Unit/Blocks/QuoteTest.php
Expand Up @@ -2,6 +2,7 @@

namespace Notion\Test\Unit\Blocks;

use Notion\Blocks\BlockFactory;
use Notion\Blocks\Quote;
use Notion\Common\Date;
use Notion\Common\RichText;
Expand Down Expand Up @@ -81,6 +82,8 @@ public function test_create_from_array(): void
$this->assertEmpty($quote->children());
$this->assertEquals("Notion quotes rock!", $quote->toString());
$this->assertFalse($quote->block()->archived());

$this->assertEquals($quote, BlockFactory::fromArray($array));
}

public function test_error_on_wrong_type(): void
Expand Down
3 changes: 3 additions & 0 deletions tests/Unit/Blocks/ToDoTest.php
Expand Up @@ -2,6 +2,7 @@

namespace Notion\Test\Unit\Blocks;

use Notion\Blocks\BlockFactory;
use Notion\Blocks\ToDo;
use Notion\Common\Date;
use Notion\Common\RichText;
Expand Down Expand Up @@ -84,6 +85,8 @@ public function test_create_from_array(): void
$this->assertEquals("Notion to dos rock!", $toDo->toString());
$this->assertTrue($toDo->checked());
$this->assertFalse($toDo->block()->archived());

$this->assertEquals($toDo, BlockFactory::fromArray($array));
}

public function test_error_on_wrong_type(): void
Expand Down
3 changes: 3 additions & 0 deletions tests/Unit/Blocks/ToggleTest.php
Expand Up @@ -2,6 +2,7 @@

namespace Notion\Test\Unit\Blocks;

use Notion\Blocks\BlockFactory;
use Notion\Blocks\Toggle;
use Notion\Common\Date;
use Notion\Common\RichText;
Expand Down Expand Up @@ -81,6 +82,8 @@ public function test_create_from_array(): void
$this->assertEmpty($toggle->children());
$this->assertEquals("Notion toggles rock!", $toggle->toString());
$this->assertFalse($toggle->block()->archived());

$this->assertEquals($toggle, BlockFactory::fromArray($array));
}

public function test_error_on_wrong_type(): void
Expand Down

0 comments on commit e44ab0b

Please sign in to comment.