Something went wrong. Try again.
@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
Something went wrong. Try again.
1.1 kB · 45 lines
PHP
12345678910111213141516171819202122232425262728293031323334353637383940414243444546<?php
final class AphrontMultipartParserTestCase extends PhutilTestCase {
public function testParser() { $map = array( array( 'data' => 'simple.txt', 'variables' => array( array('a', 'b'), ), ), );
$data_dir = dirname(__FILE__).'/data/'; foreach ($map as $test_case) { $data = Filesystem::readFile($data_dir.$test_case['data']); $data = str_replace("\n", "\r\n", $data);
$parser = id(new AphrontMultipartParser()) ->setContentType('multipart/form-data; boundary=ABCDEFG'); $parser->beginParse(); $parser->continueParse($data); $parts = $parser->endParse();
$variables = array(); foreach ($parts as $part) { if (!$part->isVariable()) { continue; }
$variables[] = array( $part->getName(), $part->getVariableValue(), ); }
$expect_variables = idx($test_case, 'variables', array()); $this->assertEqual($expect_variables, $variables); } }
}