Permalink
Browse files

fixes to tests

  • Loading branch information...
1 parent 39e8fac commit 91c966d86bc1ad7be6d7745249cc368718bfa6e1 @kaviththiranga committed Dec 15, 2012
@@ -19,14 +19,32 @@ class JMediaCollectionTest extends TestCase
* @var JMediaCollectionCss
*/
protected $object;
+ protected $files;
+
+ protected $pathToTestFiles;
+
+ protected $suffix;
+
/**
- * Sets up the fixture, for example, opens a network connection.
- * This method is called before a test is executed.
- */
+ * Sets up the fixture, for example, opens a network connection.
+ * This method is called before a test is executed.
+ */
protected function setUp()
{
- $this->object = JMediaCollection::getInstance(array('type' => 'css'));
+ $this->object = JMediaCompressor::getInstance(array('type' => 'css'));
+ $this->pathToTestFiles = JPATH_TESTS . DIRECTORY_SEPARATOR . 'media' . DIRECTORY_SEPARATOR . 'css';
+ $this->loadFiles();
+ $this->suffix = 'min';
+ }
+
+ /**
+ * Loads Necessary files
+ */
+ protected function loadFiles()
+ {
+ //
+ $this->files = glob($this->pathToTestFiles . DIRECTORY_SEPARATOR . '*.css');
}
public function testSetOptions()
@@ -40,7 +40,7 @@ class JMediaCompressorTest extends TestCase
protected function setUp()
{
$this->object = JMediaCompressor::getInstance(array('type' => 'css'));
- $this->pathToTestFiles = JPATH_BASE . '/test_files/css';
+ $this->pathToTestFiles = JPATH_TESTS . DIRECTORY_SEPARATOR . 'media' . DIRECTORY_SEPARATOR . 'css';
$this->loadFiles();
$this->suffix = 'min';
}
@@ -148,14 +148,14 @@ public function testSetOptions()
*/
public function testCompressString()
{
- $sourceCss = JPATH_BASE . '/test_files/css/comments.css';
+ $sourceCss = $this->pathToTestFiles . DIRECTORY_SEPARATOR . 'comments.css';
$expectedCss = file_get_contents(str_ireplace('.css', '.min.css', $sourceCss));
$testCss = JMediaCompressor::compressString(file_get_contents($sourceCss), array('type' => 'css'));
$this->assertEquals($expectedCss, $testCss);
- $sourceJs = JPATH_BASE . '/test_files/js/case1.js';
+ $sourceJs = JPATH_TESTS . DIRECTORY_SEPARATOR . 'media' . DIRECTORY_SEPARATOR . 'js' . DIRECTORY_SEPARATOR . 'case1.js';
$expectedJs = file_get_contents(str_ireplace('.js', '.min.js', $sourceJs));
$testJs = JMediaCompressor::compressString(file_get_contents($sourceJs), array('type' => 'js'));
@@ -168,11 +168,11 @@ public function testCompressString()
*/
public function testIsSupported()
{
- $file1 = JPATH_BASE . '/test_files/css/comments.css';
+ $file1 = JPATH_TESTS . DIRECTORY_SEPARATOR . 'media' . DIRECTORY_SEPARATOR . 'css' . DIRECTORY_SEPARATOR . 'comments.css';
$this->assertTrue(JMediaCompressor::isSupported($file1));
- $file2 = JPATH_BASE . '/test_files/js/case2.js';
+ $file2 = JPATH_TESTS . DIRECTORY_SEPARATOR . 'media' . DIRECTORY_SEPARATOR . 'js' . DIRECTORY_SEPARATOR . 'case2.js';
$this->assertTrue(JMediaCompressor::isSupported($file2));
@@ -13,7 +13,7 @@
/**
* Test class for JMediaCollectionCss.
*/
-class JMediaCombinerCssTest extends TestCase
+class JMediaCollectionCssTest extends TestCase
{
/**
* @var JMediaCollectionCss
@@ -33,7 +33,7 @@ class JMediaCombinerCssTest extends TestCase
protected function setUp()
{
$this->object = JMediaCollection::getInstance(array('type' => 'css'));
- $this->pathToTestFiles = JPATH_BASE . '/test_files/css';
+ $this->pathToTestFiles = JPATH_TESTS . DIRECTORY_SEPARATOR . 'media' . DIRECTORY_SEPARATOR . 'css';
$this->loadFiles();
$this->suffix = 'min';
}
@@ -33,7 +33,7 @@ class JMediaCombinerJsTest extends TestCase
protected function setUp()
{
$this->object = JMediaCollection::getInstance(array('type' => 'js'));
- $this->pathToTestFiles = JPATH_BASE . '/test_files/js';
+ $this->pathToTestFiles = JPATH_TESTS . DIRECTORY_SEPARATOR . 'media' . DIRECTORY_SEPARATOR . 'js';
$this->loadFiles();
$this->suffix = 'min';
}
@@ -34,7 +34,7 @@ class JMediaCompressorCssTest extends TestCase
protected function setUp()
{
$this->object = JMediaCompressor::getInstance(array('type' => 'css'));
- $this->pathToTestFiles = JPATH_BASE . '/test_files/css';
+ $this->pathToTestFiles = JPATH_TESTS . DIRECTORY_SEPARATOR . 'media' . DIRECTORY_SEPARATOR . 'css';
$this->loadFiles();
$this->suffix = 'min';
}
@@ -71,7 +71,7 @@ public function testCompress()
{
// Put the path to test files for css compressor. (Include expected result in filename.min.css file)
- $path = JPATH_BASE . '/test_files/css';
+ $path = JPATH_TESTS . DIRECTORY_SEPARATOR . 'media' . DIRECTORY_SEPARATOR . 'css';
$files = JFolder::files($path, '.', false, true, array(), array('.min.css', '.php', '.html', '.combined.css'));
@@ -35,7 +35,7 @@ class JMediaCompressorJsTest extends TestCase
protected function setUp()
{
$this->object = JMediaCompressor::getInstance(array('type' => 'js'));
- $this->pathToTestFiles = JPATH_BASE . '/test_files/js';
+ $this->pathToTestFiles = JPATH_TESTS . DIRECTORY_SEPARATOR . 'media' . DIRECTORY_SEPARATOR . 'js';
$this->loadFiles();
$this->suffix = 'min';
}
@@ -73,7 +73,7 @@ public function testCompress()
{
// Put the path to test files for java script compressor.
- $path = JPATH_BASE . '/test_files/js';
+ $path = JPATH_TESTS . DIRECTORY_SEPARATOR . 'media' . DIRECTORY_SEPARATOR . 'js';
$files = JFolder::files($path,'.',false,true, array(),array('.min.js','.php','.html','.combined.js'));
@@ -124,7 +124,7 @@ public function test_checkAlphaNum()
public function testClear()
{
- $sourceJs = JPATH_BASE . '/test_files/js/case1.js';
+ $sourceJs = JPATH_TESTS . DIRECTORY_SEPARATOR . 'media' . DIRECTORY_SEPARATOR . 'js' . DIRECTORY_SEPARATOR . 'case1.js';
$this->object->setUncompressed(JFile::read($sourceJs));
$this->object->compress();

0 comments on commit 91c966d

Please sign in to comment.