Completed
Pull Request — 3.1 (#8)
by David
08:26 queued 07:15
created

WebLibraryManagerTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 1
dl 0
loc 22
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A testToHtml() 0 19 1
1
<?php
2
3
namespace Mouf\Html\Utils\WebLibraryManager;
4
5
use Interop\Container\ServiceProviderInterface;
6
use PHPUnit\Framework\TestCase;
7
use Simplex\Container;
8
use TheCodingMachine\Discovery\Discovery;
9
10
class WebLibraryManagerTest extends TestCase
11
{
12
    public function testToHtml()
13
    {
14
        $serviceProvidersNames = Discovery::getInstance()->get(ServiceProviderInterface::class);
15
        $serviceProviders = \array_map(function(string $className) {
16
            return new $className();
17
        }, $serviceProvidersNames);
18
        $container = new Container($serviceProviders);
19
        $container->set('ROOT_URL', '/foo/bar');
20
21
        /* @var WebLibraryManager $webLibraryManager */
22
        $webLibraryManager = $container->get(WebLibraryManager::class);
23
        \ob_start();
24
        $webLibraryManager->toHtml();
25
        $content = \ob_get_clean();
26
27
        $this->assertSame('<script type="text/javascript">
28
window.rootUrl = "\/foo\/bar"</script>
29
', $content);
30
    }
31
}
32