Skip to content

Commit

Permalink
Add tests for MixExtension
Browse files Browse the repository at this point in the history
  • Loading branch information
iulyanp committed Jan 16, 2017
1 parent 57a663a commit a352311
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 0 deletions.
58 changes: 58 additions & 0 deletions Tests/Twig/ElixirMixExtensionTest.php
@@ -0,0 +1,58 @@
<?php

namespace Iulyanp\ElixirMixBundle\Tests\Twig;

use Iulyanp\ElixirMixBundle\Twig\MixExtension;

/**
* Class Test
*/
class ElixirMixExtensionTest extends \PHPUnit_Framework_TestCase
{
const WEB_DIR = __DIR__.'/stub';

/**
* @var
*/
private $mixExtension;

/**
* Set UP.
*
* Instantiate ElixirExtension for all tests
*/
public function setUp()
{
$this->mixExtension = new MixExtension(self::WEB_DIR);
}

/**
* @test
*/
public function mixFunctionReturnManifest()
{
$this->assertEquals(
'css/app-db9165hf67.css',
$this->mixExtension->mix('app.css')
);
$this->assertEquals(
'css/index-9rt53c9u67.css',
$this->mixExtension->mix('index.css')
);
$this->assertEquals(
'js/app-db9183c967.js',
$this->mixExtension->mix('app.js')
);
}

/**
* @test
*/
public function elixirFunctionThrowsErrorWhenFileNotExists()
{
$this->expectException('\Exception');
$this->expectExceptionMessage('The "css/not_existing.css" key could not be found in the manifest file. '.
'Please pass just the asset filename as a parameter to the mix() method.');
$this->mixExtension->mix('css/not_existing.css');
}
}
5 changes: 5 additions & 0 deletions Tests/Twig/stub/manifest.json
@@ -0,0 +1,5 @@
{
"app.css": "css/app-db9165hf67.css",
"index.css": "css/index-9rt53c9u67.css",
"app.js": "js/app-db9183c967.js"
}
49 changes: 49 additions & 0 deletions phpunit.xml.dist
@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
backupStaticAttributes="false"

cacheTokens="false"
colors="false"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
forceCoversAnnotation="false"
mapTestClassNameToCoveredClassName="false"
printerClass="PHPUnit_TextUI_ResultPrinter"

processIsolation="false"
stopOnError="false"
stopOnFailure="false"
stopOnIncomplete="false"
stopOnSkipped="false"
testSuiteLoaderClass="PHPUnit_Runner_StandardTestSuiteLoader"

strict="false"
verbose="false"
>

<testsuites>
<testsuite name="AllTests">
<directory>Tests</directory>
</testsuite>
</testsuites>

<filter>
<blacklist>
<directory suffix=".php"></directory>
<file></file>
<exclude>
<directory suffix=".php"></directory>
<file></file>
</exclude>
</blacklist>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php"></directory>
<file></file>
<exclude>
<directory suffix=".php"></directory>
<file></file>
</exclude>
</whitelist>
</filter>
</phpunit>

0 comments on commit a352311

Please sign in to comment.