TableCellTest.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. declare(strict_types=1);
  3. /*
  4. * This file is part of the league/commonmark package.
  5. *
  6. * (c) Colin O'Dell <colinodell@gmail.com>
  7. *
  8. * For the full copyright and license information, please view the LICENSE
  9. * file that was distributed with this source code.
  10. */
  11. namespace League\CommonMark\Tests\Unit\Extension\Table;
  12. use League\CommonMark\Extension\Table\TableCell;
  13. use PHPUnit\Framework\TestCase;
  14. final class TableCellTest extends TestCase
  15. {
  16. public function testDefaultType(): void
  17. {
  18. $this->assertSame(TableCell::TYPE_DATA, (new TableCell())->getType());
  19. }
  20. public function testTypeConstructorArgument(): void
  21. {
  22. $this->assertSame(TableCell::TYPE_HEADER, (new TableCell(TableCell::TYPE_HEADER))->getType());
  23. $this->assertSame(TableCell::TYPE_DATA, (new TableCell(TableCell::TYPE_DATA))->getType());
  24. }
  25. public function testSetType(): void
  26. {
  27. $cell = new TableCell(TableCell::TYPE_HEADER);
  28. $cell->setType(TableCell::TYPE_DATA);
  29. $this->assertSame(TableCell::TYPE_DATA, $cell->getType());
  30. }
  31. public function testDefaultAlign(): void
  32. {
  33. $this->assertNull((new TableCell())->getAlign());
  34. }
  35. public function testAlignConstructorArgument(): void
  36. {
  37. $this->assertNull((new TableCell(TableCell::TYPE_DATA, null))->getAlign());
  38. $this->assertSame(TableCell::ALIGN_LEFT, (new TableCell(TableCell::TYPE_DATA, TableCell::ALIGN_LEFT))->getAlign());
  39. $this->assertSame(TableCell::ALIGN_CENTER, (new TableCell(TableCell::TYPE_DATA, TableCell::ALIGN_CENTER))->getAlign());
  40. $this->assertSame(TableCell::ALIGN_RIGHT, (new TableCell(TableCell::TYPE_DATA, TableCell::ALIGN_RIGHT))->getAlign());
  41. }
  42. public function testSetAlign(): void
  43. {
  44. $cell = new TableCell();
  45. $cell->setAlign(TableCell::ALIGN_CENTER);
  46. $this->assertSame(TableCell::ALIGN_CENTER, $cell->getAlign());
  47. }
  48. }