Skip to content

Commit eab674c

Browse files
committed
replace dispose with exit methods
1 parent fb04769 commit eab674c

16 files changed

+42
-64
lines changed

packages/php-wasm/node/src/test/php-crash.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ describe.each(['7.3', '7.4', '8.0', '8.1'])(
2424
});
2525

2626
afterEach(async () => {
27-
php?.[Symbol.dispose]?.();
27+
php.exit();
2828
});
2929

3030
function unhandledRejectionHandler(error: any) {

packages/php-wasm/node/src/test/php-dynamic-loading.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ describe.each(SupportedPHPVersions)('PHP %s', (phpVersion) => {
1313
});
1414

1515
afterEach(async () => {
16-
php?.[Symbol.dispose]?.();
16+
php.exit();
1717
});
1818

1919
it('does not load dynamically by default', async () => {

packages/php-wasm/node/src/test/php-file-get-contents.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ const httpsServer = https.createServer(
8989
});
9090

9191
afterEach(async () => {
92-
php?.[Symbol.dispose]?.();
92+
php.exit();
9393
});
9494

9595
describe.each(Object.keys(topOfTheStack))(

packages/php-wasm/node/src/test/php-fopen.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ const httpsServer = https.createServer(
9292
});
9393

9494
afterEach(async () => {
95-
php?.[Symbol.dispose]?.();
95+
php.exit();
9696
});
9797

9898
describe.each(Object.keys(topOfTheStack))(

packages/php-wasm/node/src/test/php-fsockopen.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ const httpsServer = https.createServer(
9494
});
9595

9696
afterEach(async () => {
97-
php?.[Symbol.dispose]?.();
97+
php.exit();
9898
});
9999

100100
describe.each(Object.keys(topOfTheStack))(

packages/php-wasm/node/src/test/php-gethostbyname.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ const httpsServer = https.createServer(
9393
});
9494

9595
afterEach(async () => {
96-
php?.[Symbol.dispose]?.();
96+
php.exit();
9797
});
9898

9999
describe.each(Object.keys(topOfTheStack))(

packages/php-wasm/node/src/test/php-ini.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ custom_setting = true
2323
});
2424

2525
afterEach(async () => {
26-
php?.[Symbol.dispose]?.();
26+
php.exit();
2727
});
2828

2929
describe('getPhpIniEntries', () => {

packages/php-wasm/node/src/test/php-memory.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ describe.each(phpVersions)('PHP %s – memory allocation', (phpVersion) => {
1616
});
1717

1818
afterEach(async () => {
19-
php?.[Symbol.dispose]?.();
19+
php.exit();
2020
});
2121

2222
it('can concat large string out of many small strings without reaching Out-of-memory condition', async () => {

packages/php-wasm/node/src/test/php-mysqli.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ const httpsServer = https.createServer(
129129
});
130130

131131
afterEach(async () => {
132-
php?.[Symbol.dispose]?.();
132+
php.exit();
133133
});
134134

135135
describe.each(Object.keys(topOfTheStack))(

packages/php-wasm/node/src/test/php-networking.spec.ts

Lines changed: 24 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -239,21 +239,16 @@ describe.each(SupportedPHPVersions)('PHP %s', (phpVersion) => {
239239
}
240240
});
241241

242-
it(
243-
'should support HTTPS requests',
244-
async () => {
245-
const php = new PHP(await loadNodeRuntime(phpVersion));
246-
await setPhpIniEntries(php, {
247-
'openssl.cafile': '/tmp/ca-bundle.crt',
248-
allow_url_fopen: 1,
249-
disable_functions: '',
250-
});
251-
php.writeFile(
252-
'/tmp/ca-bundle.crt',
253-
rootCertificates.join('\n')
254-
);
255-
const { text } = await php.run({
256-
code: `<?php
242+
it('should support HTTPS requests', async () => {
243+
const php = new PHP(await loadNodeRuntime(phpVersion));
244+
await setPhpIniEntries(php, {
245+
'openssl.cafile': '/tmp/ca-bundle.crt',
246+
allow_url_fopen: 1,
247+
disable_functions: '',
248+
});
249+
php.writeFile('/tmp/ca-bundle.crt', rootCertificates.join('\n'));
250+
const { text } = await php.run({
251+
code: `<?php
257252
$ch = curl_init();
258253
curl_setopt($ch, CURLOPT_URL, "https://api.wordpress.org/stats/php/1.0/");
259254
curl_setopt($ch, CURLOPT_TCP_NODELAY, 0);
@@ -263,22 +258,18 @@ describe.each(SupportedPHPVersions)('PHP %s', (phpVersion) => {
263258
$json = json_decode($result, true);
264259
var_dump(array_key_exists('8.3', $json));
265260
`,
266-
});
267-
expect(text).toContain('bool(true)');
268-
},
269-
{ timeout: 4000 }
270-
);
261+
});
262+
expect(text).toContain('bool(true)');
263+
}, 8000);
271264

272-
it(
273-
'should support HTTPS requests when certificate verification is disabled',
274-
async () => {
275-
const php = new PHP(await loadNodeRuntime(phpVersion));
276-
await setPhpIniEntries(php, {
277-
allow_url_fopen: 1,
278-
disable_functions: '',
279-
});
280-
const { text } = await php.run({
281-
code: `<?php
265+
it('should support HTTPS requests when certificate verification is disabled', async () => {
266+
const php = new PHP(await loadNodeRuntime(phpVersion));
267+
await setPhpIniEntries(php, {
268+
allow_url_fopen: 1,
269+
disable_functions: '',
270+
});
271+
const { text } = await php.run({
272+
code: `<?php
282273
$ch = curl_init();
283274
curl_setopt($ch, CURLOPT_URL, "https://api.wordpress.org/stats/php/1.0/");
284275
curl_setopt($ch, CURLOPT_TCP_NODELAY, 0);
@@ -290,11 +281,9 @@ describe.each(SupportedPHPVersions)('PHP %s', (phpVersion) => {
290281
$json = json_decode($result, true);
291282
var_dump(array_key_exists('8.3', $json));
292283
`,
293-
});
294-
expect(text).toContain('bool(true)');
295-
},
296-
{ timeout: 4000 }
297-
);
284+
});
285+
expect(text).toContain('bool(true)');
286+
}, 8000);
298287

299288
it('should close server when runtime is exited', async () => {
300289
const id = await loadNodeRuntime(phpVersion);

packages/php-wasm/node/src/test/php-request-handler.spec.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,7 @@ describe.each(configsForRequestTests)(
9191
});
9292

9393
afterEach(async () => {
94-
php?.[Symbol.dispose]?.();
95-
await handler?.[Symbol.asyncDispose]?.();
94+
php.exit();
9695
});
9796

9897
it('should execute a PHP file', async () => {
@@ -687,7 +686,7 @@ describe.each(SupportedPHPVersions)(
687686
});
688687

689688
afterEach(async () => {
690-
await handler?.[Symbol.asyncDispose]?.();
689+
(await handler.getPrimaryPhp()).exit();
691690
});
692691

693692
it.each([

packages/php-wasm/node/src/test/php-sqlite3.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ describe(`SQLite3 – ${runtimeMode}`, () => {
277277
});
278278

279279
afterEach(async () => {
280-
php?.[Symbol.dispose]?.();
280+
php.exit();
281281
});
282282

283283
describe.each(Object.keys(topOfTheStack))('%s', (networkCallKey) => {

packages/php-wasm/node/src/test/php-vars.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ describe('phpVar', () => {
1616
});
1717

1818
afterEach(async () => {
19-
php?.[Symbol.dispose]?.();
19+
php.exit();
2020
});
2121

2222
const data = [

packages/php-wasm/node/src/test/php.spec.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,7 @@ describe.each(SupportedPHPVersions)('PHP %s', (phpVersion) => {
8888
await setPhpIniEntries(php, { disable_functions: '' });
8989
});
9090
afterEach(async () => {
91-
// Clean up
92-
try {
93-
php.exit(0);
94-
} catch {
95-
// ignore exit-related exceptions
96-
}
91+
php.exit();
9792
});
9893

9994
describe('php.runStream()', () => {

packages/php-wasm/node/src/test/symlinks.spec.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,10 @@ testSymlinks.forEach(({ name, sourcePath, symlinkPath }) => {
7373
}
7474
});
7575
afterEach(async () => {
76-
// Clean up
77-
try {
78-
if (fs.existsSync(symlinkPath)) {
79-
fs.unlinkSync(symlinkPath);
80-
}
81-
php.exit(0);
82-
} catch {
83-
// ignore exit-related exceptions
76+
if (fs.existsSync(symlinkPath)) {
77+
fs.unlinkSync(symlinkPath);
8478
}
79+
php.exit();
8580
});
8681

8782
describe('Test symlinks', () => {

packages/php-wasm/node/src/test/write-files.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ describe('writeFiles', () => {
1313
});
1414

1515
afterEach(async () => {
16-
php?.[Symbol.dispose]?.();
16+
php.exit();
1717
});
1818

1919
it('removes the previous directory contents', async () => {

0 commit comments

Comments
 (0)