Skip to content

Commit 63ad07d

Browse files
committed
Update TransloaditTest.php
1 parent 434548a commit 63ad07d

File tree

1 file changed

+32
-2
lines changed

1 file changed

+32
-2
lines changed

test/simple/TransloaditTest.php

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,10 @@ private function getExpectedUrl(array $params): ?string {
151151
return null;
152152
}
153153

154-
if (system('which tsx > /dev/null 2>&1') === false) {
155-
throw new \RuntimeException('tsx not found. Please install it with: npm install -g tsx');
154+
// Check for tsx before trying to use it
155+
exec('which tsx 2>/dev/null', $output, $returnVar);
156+
if ($returnVar !== 0) {
157+
throw new \RuntimeException('tsx command not found. Please install it with: npm install -g tsx');
156158
}
157159

158160
$scriptPath = __DIR__ . '/../../tool/node-smartcdn-sig.ts';
@@ -324,4 +326,32 @@ public function testSignedSmartCDNUrl() {
324326
);
325327
$this->assertParityWithNode($url, $params);
326328
}
329+
330+
public function testTsxRequiredForParityTesting(): void {
331+
if (getenv('TEST_NODE_PARITY') !== '1') {
332+
$this->markTestSkipped('Parity testing not enabled');
333+
}
334+
335+
// Temporarily override PATH to simulate missing tsx
336+
$originalPath = getenv('PATH');
337+
putenv('PATH=/usr/bin:/bin');
338+
339+
try {
340+
$params = [
341+
'workspace' => 'test',
342+
'template' => 'test',
343+
'input' => 'test.jpg',
344+
'auth_key' => 'test',
345+
'auth_secret' => 'test'
346+
];
347+
$this->getExpectedUrl($params);
348+
$this->fail('Expected RuntimeException when tsx is not available');
349+
} catch (\RuntimeException $e) {
350+
$this->assertStringContainsString('tsx command not found', $e->getMessage());
351+
$this->assertStringContainsString('npm install -g tsx', $e->getMessage());
352+
} finally {
353+
// Restore original PATH
354+
putenv("PATH=$originalPath");
355+
}
356+
}
327357
}

0 commit comments

Comments
 (0)