@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.)
hq.recaptime.dev/wiki/Phorge
phorge
phabricator
1<?php
2
3final class CelerityResourceTransformerTestCase extends PhabricatorTestCase {
4
5 public function testTransformation() {
6 $files = dirname(__FILE__).'/transformer/';
7 foreach (Filesystem::listDirectory($files) as $file) {
8 $name = basename($file);
9 $data = Filesystem::readFile($files.'/'.$file);
10 $parts = preg_split('/^~~~+\n/m', $data);
11 $parts = array_merge($parts, array(null));
12
13 list($options, $in, $expect) = $parts;
14
15 $parser = new PhutilSimpleOptions();
16 $options = $parser->parse($options) + array(
17 'minify' => false,
18 'name' => $name,
19 );
20
21 $xformer = new CelerityResourceTransformer();
22 $xformer->setRawURIMap(
23 array(
24 '/rsrc/example.png' => '/res/hash/example.png',
25 ));
26 $xformer->setMinify($options['minify']);
27
28 $result = $xformer->transformResource($options['name'], $in);
29
30 $this->assertEqual(rtrim($expect), rtrim($result), $file);
31 }
32 }
33
34}