From 82fa6be8a0295a3932df871e88fc8c8d77aa71d4 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Thu, 21 Mar 2024 08:10:33 +0100 Subject: [PATCH] use local PHP web server to test HTTP stream wrappers --- Tests/Fixtures/web/index.php | 1 + Tests/Fixtures/web/logo_symfony_header.png | Bin 0 -> 1613 bytes Tests/Part/DataPartTest.php | 16 ++++++++++++---- composer.json | 1 + 4 files changed, 14 insertions(+), 4 deletions(-) create mode 100644 Tests/Fixtures/web/index.php create mode 100644 Tests/Fixtures/web/logo_symfony_header.png diff --git a/Tests/Fixtures/web/index.php b/Tests/Fixtures/web/index.php new file mode 100644 index 0000000..b3d9bbc --- /dev/null +++ b/Tests/Fixtures/web/index.php @@ -0,0 +1 @@ +P+)L?kDsr<&)@GO8iI-d00p^8L_t(|+TEM!dZRiFh9%=g7;pD~ zwI}6ZzB(8;nKJD&yuYTMVCl0KFQjyi)<#6Mp6LE4>r(;ITc-QME|w#UrF)|0T>4~T zx*aTKKz4L9bSh)wM0a8?U*qUDa4fIjneM@q%4{5WD0L7g3u)_D4#1)Wz1Bk z#1XoAW&(90lBP>34+4R|-LX)PxvY3eXH}Xo370YbN`T`@Q%ir}H(l%KTI8s4771lT zpB1?|`u1-KPNgMGL`v7AaX>?QV);h}Po-tvx??a?toF9PET!S#o2BuuZ6+^5=z~p|JQ9!92I2 zVF)gI9S-Ad))Rrad6S=ea-9Rrkl$>&(h!J%)bLcQ*Q(6|yL~q10x~xOr49#F=YSI# zf?Xpcb5(&5tGbiuh`?+GIPTfx(ZaO3lN`4@L)UKTn4rdM;{QF3A5U5)6RW>YMEv?8 zd7$^8C#y)=P!(6fAES7~HR*k|KBK@k>$(>;+h(nPKqi!D`g>_y=W?6VY4d~xyHhye z8S`d4O-q_Gas_fWvzp+0rY(0<6Od)M2N+LPYg2eoI;j4Fj?=5(K81`n_~06PM2-mu zH-8k&8G7NNf?(4WlCIXL&lznyn<#0{6Y!yjrWQ2Hz>o7BNdP0H;9>yv^7R)DIQq`u_J7Wn&DcA&Iq?J&Aio0P|C%2Cpoi{U9``ryk z5KQk27W$0TU!g!S0@l;G`ym~{1`TBQ*_1P=3mRqZHLAv1T`5?97A#%Cwi;EiPR)vh zY&82*b2%Z=8E61pb9zQfUKwFG5)A9oHc#wf_hM%B)L2dkbOL`lZXL zy#8~>{^@POh>Ll)5osV8trGQA>ls9BBQq@Z$kYefhOAl*o9_s=C?b5WxUU4yjde^y zmoUy~KfapD%@!Ix?hgf1>g=U6j|9Vd8y+{TQ7LDb@g0gZ7r0m|-xrJ@Fo=T-L%|eV z>%$o8;aiw=Sc!rdt<9X8(>bP0eM2xbCed2Egd7_RMmVRhFXHn!z_zp301@&O?oz%b zn517*W5L`Bk2VT?L`H{K z15CyzjG#L20J#yIpo7{93;0j{d`ZSGRU6VAJ{E2T2Zm#vZ9nHWuD*uQm3MYoN;?sw zxw{Qn=o*v}5i@=BjhsPz_q;cwJx5mbBDk&mB^0c8k{ahoKhXPz`?%ZrEu{ZiGa|w? zrFB(tFNR3j<*Kh~sRb$VV~njs z@oR+F_1X~e>f@(@bwyn`6mUuXD%{!r0{rzcR?3)nzY?eMO75qD^{l`11@WNXtDq3V zVwo=Edh3$QImy!fU`W2XT+m&UyrCPzW)1~}8ES8g(*JX>zgGGWdRYnkHtkA|00000 LNkvXXu0mjf1C89g literal 0 HcmV?d00001 diff --git a/Tests/Part/DataPartTest.php b/Tests/Part/DataPartTest.php index 34a379c..d0a6927 100644 --- a/Tests/Part/DataPartTest.php +++ b/Tests/Part/DataPartTest.php @@ -18,6 +18,8 @@ use Symfony\Component\Mime\Header\ParameterizedHeader; use Symfony\Component\Mime\Header\UnstructuredHeader; use Symfony\Component\Mime\Part\DataPart; +use Symfony\Component\Process\PhpExecutableFinder; +use Symfony\Component\Process\Process; class DataPartTest extends TestCase { @@ -134,16 +136,22 @@ public function testFromPathWithNotAFile() DataPart::fromPath(__DIR__.'/../Fixtures/mimetypes/'); } - /** - * @group network - */ public function testFromPathWithUrl() { if (!\in_array('https', stream_get_wrappers())) { $this->markTestSkipped('"https" stream wrapper is not enabled.'); } - $p = DataPart::fromPath($file = 'https://symfony.com/images/common/logo/logo_symfony_header.png'); + $finder = new PhpExecutableFinder(); + $process = new Process(array_merge([$finder->find(false)], $finder->findArguments(), ['-dopcache.enable=0', '-dvariables_order=EGPCS', '-S', '127.0.0.1:8057'])); + $process->setWorkingDirectory(__DIR__.'/../Fixtures/web'); + $process->start(); + + do { + usleep(50000); + } while (!@fopen('http://127.0.0.1:8057', 'r')); + + $p = DataPart::fromPath($file = 'http://localhost:8057/logo_symfony_header.png'); $content = file_get_contents($file); $this->assertEquals($content, $p->getBody()); $maxLineLength = 76; diff --git a/composer.json b/composer.json index 11823ef..3bb6095 100644 --- a/composer.json +++ b/composer.json @@ -26,6 +26,7 @@ "egulias/email-validator": "^2.1.10|^3.1|^4", "phpdocumentor/reflection-docblock": "^3.0|^4.0|^5.0", "symfony/dependency-injection": "^4.4|^5.0|^6.0", + "symfony/process": "^5.4|^6.4", "symfony/property-access": "^4.4|^5.1|^6.0", "symfony/property-info": "^4.4|^5.1|^6.0", "symfony/serializer": "^5.4.35|~6.3.12|^6.4.3"