@@ 28-46 (lines=19) @@ | ||
25 | $this->assertEquals('mailto:[email protected]', $urlHelper->replaceUrl('[email protected]')); |
|
26 | } |
|
27 | ||
28 | public function testReplaceUrlWithInternalLink() |
|
29 | { |
|
30 | $stmt = $this->getMockBuilder(Statement::class)->getMock(); |
|
31 | $stmt->expects($this->once())->method('fetch')->willReturn(['id' => 18, 'url' => 'abc']); |
|
32 | $conn = $this->getMockBuilder(Connection::class)->disableOriginalConstructor()->getMock(); |
|
33 | $conn->expects($this->once())->method('executeQuery')->willReturn($stmt); |
|
34 | $em = $this->getMockBuilder(EntityManager::class)->disableOriginalConstructor()->getMock(); |
|
35 | $em->expects($this->once())->method('getConnection')->willReturn($conn); |
|
36 | $router = $this->getMockBuilder(RouterInterface::class)->getMock(); |
|
37 | $router->method('generate')->with('_slug', ['url' => 'abc'])->willReturn('/abc'); |
|
38 | $logger = $this->getMockBuilder(LoggerInterface::class)->getMock(); |
|
39 | $domainConfig = $this->getMockBuilder(DomainConfigurationInterface::class)->getMock(); |
|
40 | ||
41 | $urlHelper = new URLHelper($em, $router, $logger, $domainConfig); |
|
42 | $this->assertEquals('/abc', $urlHelper->replaceUrl('[NT18]')); |
|
43 | ||
44 | //Second call to replaceUrl should not execute query again |
|
45 | $this->assertEquals('/abc', $urlHelper->replaceUrl('[NT18]')); |
|
46 | } |
|
47 | ||
48 | public function testReplaceUrlWithMediaLink() |
|
49 | { |
|
@@ 48-66 (lines=19) @@ | ||
45 | $this->assertEquals('/abc', $urlHelper->replaceUrl('[NT18]')); |
|
46 | } |
|
47 | ||
48 | public function testReplaceUrlWithMediaLink() |
|
49 | { |
|
50 | $stmt = $this->getMockBuilder(Statement::class)->getMock(); |
|
51 | $stmt->expects($this->once())->method('fetch')->willReturn(['id' => 18, 'url' => '/uploads/media/5e24be27412e6/test.svg']); |
|
52 | $conn = $this->getMockBuilder(Connection::class)->disableOriginalConstructor()->getMock(); |
|
53 | $conn->expects($this->once())->method('executeQuery')->willReturn($stmt); |
|
54 | $em = $this->getMockBuilder(EntityManager::class)->disableOriginalConstructor()->getMock(); |
|
55 | $em->expects($this->once())->method('getConnection')->willReturn($conn); |
|
56 | $router = $this->getMockBuilder(RouterInterface::class)->getMock(); |
|
57 | $router->method('generate')->with('_slug', ['url' => 'abc'])->willReturn('/abc'); |
|
58 | $logger = $this->getMockBuilder(LoggerInterface::class)->getMock(); |
|
59 | $domainConfig = $this->getMockBuilder(DomainConfigurationInterface::class)->getMock(); |
|
60 | ||
61 | $urlHelper = new URLHelper($em, $router, $logger, $domainConfig); |
|
62 | $this->assertEquals('/uploads/media/5e24be27412e6/test.svg', $urlHelper->replaceUrl('[M18]')); |
|
63 | ||
64 | //Second call to replaceUrl should not execute query again |
|
65 | $this->assertEquals('/uploads/media/5e24be27412e6/test.svg', $urlHelper->replaceUrl('[M18]')); |
|
66 | } |
|
67 | } |
|
68 |