|
6 | 6 | use PHPUnit\Framework\Attributes\DataProvider; |
7 | 7 | use PHPUnit\Framework\TestCase; |
8 | 8 | use Windwalker\Test\Traits\BaseAssertionTrait; |
| 9 | +use function PHPUnit\Framework\assertEquals; |
9 | 10 |
|
10 | 11 | /** |
11 | 12 | * The AutolinkTest class. |
@@ -157,7 +158,7 @@ public function testTextLimit() |
157 | 158 | ); |
158 | 159 |
|
159 | 160 | $this->instance->textLimit(function ($url) { |
160 | | - return \Asika\Autolink\Autolink::shortenUrl($url); |
| 161 | + return Autolink::shortenUrl($url); |
161 | 162 | }); |
162 | 163 |
|
163 | 164 | self::assertEquals( |
@@ -385,6 +386,27 @@ public function testGetAndSetLinkBuilder() |
385 | 386 | self::assertInstanceOf('Closure', $this->instance->getLinkBuilder()); |
386 | 387 | } |
387 | 388 |
|
| 389 | + public function testIgnoreTrailingDot(): void |
| 390 | + { |
| 391 | + $txt = 'Link to https://google.com.'; |
| 392 | + |
| 393 | + $html = $this->instance->convert($txt); |
| 394 | + |
| 395 | + assertEquals( |
| 396 | + 'Link to <a href="https://google.com">https://google.com</a>.', |
| 397 | + $html, |
| 398 | + ); |
| 399 | + |
| 400 | + $txt = 'Link to https://google.com/search?foo=yoo.'; |
| 401 | + |
| 402 | + $html = $this->instance->convert($txt); |
| 403 | + |
| 404 | + assertEquals( |
| 405 | + 'Link to <a href="https://google.com/search?foo=yoo">https://google.com/search?foo=yoo</a>.', |
| 406 | + $html, |
| 407 | + ); |
| 408 | + } |
| 409 | + |
388 | 410 | /** |
389 | 411 | * urlProvider |
390 | 412 | * |
@@ -431,6 +453,6 @@ public static function urlProvider() |
431 | 453 | #[DataProvider('urlProvider')] |
432 | 454 | public function testShortenUrl($url, $expect, $limit, $dots) |
433 | 455 | { |
434 | | - self::assertEquals($expect, \Asika\Autolink\Autolink::shortenUrl($url, $limit, $dots)); |
| 456 | + self::assertEquals($expect, Autolink::shortenUrl($url, $limit, $dots)); |
435 | 457 | } |
436 | 458 | } |
0 commit comments