|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +use PHPUnit\Framework\TestCase; |
| 6 | +use Smeghead\PhpClassDiagram\Php\PhpType; |
| 7 | + |
| 8 | +final class PhpTypeTest extends TestCase |
| 9 | +{ |
| 10 | + public function testEquals_different_name(): void |
| 11 | + { |
| 12 | + $sut = new PhpType(['hoge'], '', 'Product'); |
| 13 | + $other = new PhpType(['hoge'], '', 'ProductXXX'); |
| 14 | + |
| 15 | + $this->assertFalse($sut->equals($other)); |
| 16 | + } |
| 17 | + public function testEquals_different_namespace(): void |
| 18 | + { |
| 19 | + $sut = new PhpType(['hoge'], '', 'Product'); |
| 20 | + $other = new PhpType(['hoge', 'fuga'], '', 'Product'); |
| 21 | + |
| 22 | + $this->assertFalse($sut->equals($other)); |
| 23 | + } |
| 24 | + public function testEquals_same_name(): void |
| 25 | + { |
| 26 | + $sut = new PhpType(['hoge'], '', 'Product'); |
| 27 | + $other = new PhpType(['hoge'], '', 'Product'); |
| 28 | + |
| 29 | + $this->assertTrue($sut->equals($other)); |
| 30 | + } |
| 31 | + public function testEquals_braces(): void |
| 32 | + { |
| 33 | + $sut = new PhpType(['hoge'], '', 'Product'); |
| 34 | + $other = new PhpType(['hoge'], '', 'Product[]'); |
| 35 | + |
| 36 | + $this->assertTrue($sut->equals($other)); |
| 37 | + } |
| 38 | + public function testEquals_array_expression(): void |
| 39 | + { |
| 40 | + $sut = new PhpType(['hoge'], '', 'Product'); |
| 41 | + $other = new PhpType(['hoge'], '', 'array<Product>'); |
| 42 | + |
| 43 | + $this->assertTrue($sut->equals($other)); |
| 44 | + } |
| 45 | + public function testEquals_array_expression_int_and_product(): void |
| 46 | + { |
| 47 | + $sut = new PhpType(['hoge'], '', 'Product'); |
| 48 | + $other = new PhpType(['hoge'], '', 'array<int, Product>'); |
| 49 | + |
| 50 | + $this->assertTrue($sut->equals($other)); |
| 51 | + } |
| 52 | + public function testEquals_array_expression_string_and_product(): void |
| 53 | + { |
| 54 | + $sut = new PhpType(['hoge'], '', 'Product'); |
| 55 | + $other = new PhpType(['hoge'], '', 'array<string, Product>'); |
| 56 | + |
| 57 | + $this->assertTrue($sut->equals($other)); |
| 58 | + } |
| 59 | +} |
0 commit comments