1<?php
2
3/**
4 * SCSSPHP
5 *
6 * @copyright 2012-2020 Leaf Corcoran
7 *
8 * @license http://opensource.org/licenses/MIT MIT
9 *
10 * @link http://scssphp.github.io/scssphp
11 */
12
13namespace ScssPhp\ScssPhp\Tests;
14
15use PHPUnit\Framework\TestCase;
16use ScssPhp\ScssPhp\Compiler;
17use ScssPhp\ScssPhp\Logger\QuietLogger;
18
19class FrameworkTest extends TestCase
20{
21    public function testBootstrap()
22    {
23        $compiler = new Compiler();
24        $compiler->setLogger(new QuietLogger());
25
26        $entrypoint = dirname(__DIR__) . '/vendor/twbs/bootstrap/scss/bootstrap.scss';
27
28        $result = $compiler->compileString(file_get_contents($entrypoint), $entrypoint);
29
30        $this->assertNotEmpty($result->getCss());
31    }
32
33    public function testBootstrap4()
34    {
35        $compiler = new Compiler();
36        $compiler->setLogger(new QuietLogger());
37
38        $entrypoint = dirname(__DIR__) . '/vendor/twbs/bootstrap4/scss/bootstrap.scss';
39
40        $result = $compiler->compileString(file_get_contents($entrypoint), $entrypoint);
41
42        $this->assertNotEmpty($result->getCss());
43    }
44
45    public function testBootstrap4CustomSettings()
46    {
47        $compiler = new Compiler();
48        $compiler->addImportPath(dirname(__DIR__) . '/vendor/twbs/bootstrap4/scss');
49        $compiler->setLogger(new QuietLogger());
50
51        $scss = <<<'SCSS'
52$enable-shadows: true;
53$enable-gradients: true;
54
55@import "bootstrap";
56SCSS;
57
58        $result = $compiler->compileString($scss);
59
60        $this->assertNotEmpty($result->getCss());
61    }
62
63    public function testFoundation()
64    {
65        $compiler = new Compiler();
66        $compiler->setLogger(new QuietLogger());
67
68        $entrypoint = dirname(__DIR__) . '/vendor/zurb/foundation/assets/foundation.scss';
69
70        $result = $compiler->compileString(file_get_contents($entrypoint), $entrypoint);
71
72        $this->assertNotEmpty($result->getCss());
73    }
74
75    /**
76     * @dataProvider provideBourbonEntrypoints
77     */
78    public function testBourbon($entrypoint)
79    {
80        $compiler = new Compiler();
81        $compiler->setLogger(new QuietLogger());
82        $compiler->addImportPath(dirname(__DIR__) . '/vendor/thoughtbot/bourbon');
83        $compiler->addImportPath(dirname(__DIR__) . '/vendor/thoughtbot/bourbon/spec/fixtures');
84
85        $result = $compiler->compileString(file_get_contents($entrypoint), $entrypoint);
86
87        $this->assertNotEmpty($result->getCss());
88    }
89
90    public static function provideBourbonEntrypoints()
91    {
92        $iterator = new \RecursiveDirectoryIterator(dirname(__DIR__) . '/vendor/thoughtbot/bourbon/spec/fixtures', \FilesystemIterator::SKIP_DOTS);
93        $iterator = new \RecursiveCallbackFilterIterator($iterator, function (\SplFileInfo $current) {
94            return $current->isDir() || $current->getFilename()[0] !== '_';
95        });
96
97        /** @var \SplFileInfo $file */
98        foreach (new \RecursiveIteratorIterator($iterator) as $file) {
99            yield [$file->getRealPath()];
100        }
101    }
102}
103