Spamworldpro Mini Shell
Spamworldpro


Server : Apache
System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64
User : corals ( 1002)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/corals/demo.cartinsight.co/vendor/marcusschwarz/lesserphp/tests/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/demo.cartinsight.co/vendor/marcusschwarz/lesserphp/tests/InputTest.php
<?php

require_once __DIR__ . "/../lessc.inc.php";

use PHPUnit\Framework\TestCase;

// Runs all the tests in inputs/ and compares their output to ouputs/

function _dump($value) {
	fwrite(STDOUT, print_r($value, true));
}

function _quote($str) {
	return preg_quote($str, "/");
}

class InputTest extends TestCase {
	protected static $importDirs = array("inputs/test-imports");

	protected static $testDirs = array(
		"inputs" => "outputs",
		"inputs_lessjs" => "outputs_lessjs",
	);

	public function setUp() {
		$this->less = new lessc();
		$this->less->importDir = array_map(function($path) {
			return __DIR__ . "/" . $path;
		}, self::$importDirs);
	}

	/**
	 * @dataProvider fileNameProvider
	 */
	public function testInputFile($inFname) {
		if ($pattern = getenv("BUILD")) {
			return $this->buildInput($inFname);
		}

		$outFname = self::outputNameFor($inFname);

		if (!is_readable($outFname)) {
			$this->fail("$outFname is missing, ".
				"consider building tests with BUILD=true");
		}

		$input = file_get_contents($inFname);
		$output = file_get_contents($outFname);

		$this->assertEquals($output, $this->less->parse($input));
	}

	public function fileNameProvider() {
		return array_map(function($a) { return array($a); },
			self::findInputNames());
	}

	// only run when env is set
	public function buildInput($inFname) {
		$css = $this->less->parse(file_get_contents($inFname));
		file_put_contents(self::outputNameFor($inFname), $css);
	}

	static public function findInputNames($pattern="*.less") {
		$files = array();
		foreach (self::$testDirs as $inputDir => $outputDir) {
			$files = array_merge($files, glob(__DIR__ . "/" . $inputDir . "/" . $pattern));
		}

		return array_filter($files, "is_file");
	}

	static public function outputNameFor($input) {
		$front = _quote(__DIR__ . "/");
		$out = preg_replace("/^$front/", "", $input);

		foreach (self::$testDirs as $inputDir => $outputDir) {
			$in = _quote($inputDir . "/");
			$rewritten = preg_replace("/$in/", $outputDir . "/", $out);
			if ($rewritten != $out) {
				$out = $rewritten;
				break;
			}
		}

		$out = preg_replace("/.less$/", ".css", $out);

		return __DIR__ . "/" . $out;
	}
}


Spamworldpro Mini