3 class JSIterator implements Iterator {
4 private $data = array();
6 private $test_files = array();
8 public function __construct($directory, $expectFiles = TRUE) {
9 $root_dir = realpath('tests/jssource/'.$directory);
10 $test_dir = $root_dir.'/test/';
12 $expect_dir = $root_dir.'/expect/';
15 $test_contents = scandir($test_dir);
16 foreach($test_contents as $possible_file) {
17 $test_file = $test_dir.$possible_file;
19 $expect_file = $expect_dir.$possible_file;
20 if(is_file($test_file) && is_file($expect_file)) {
21 $this->test_files[] = array($test_file, $expect_file);
24 if(is_file($test_file)) {
25 $this->test_files[] = array($test_file);
31 public function current() {
33 foreach($this->test_files[$this->key] as $file) {
34 $ret[] = file_get_contents($file);
39 public function key() {
43 public function rewind() {
44 reset($this->test_files);
45 $this->data = array();
49 public function valid() {
50 return $this->key < count($this->test_files);
53 public function next() {
58 class SugarJSMinTest extends PHPUnit_Framework_TestCase {
60 * @dataProvider minifyProvider
62 public function testMinify($unminified, $minified) {
63 require_once('jssource/jsmin.php');
64 $this->assertEquals(SugarMin::minify($unminified), $minified);
67 public function minifyProvider() {
68 return new JSIterator('minify');