Skip to content

Commit

Permalink
Test php relative import path
Browse files Browse the repository at this point in the history
  • Loading branch information
yandeu committed Mar 17, 2024
1 parent 11f6713 commit 9e94194
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions test/data/header.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p>I am the header</p>
5 changes: 5 additions & 0 deletions test/data/sub/content.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php
include "../header.php";
?>

<p>I am the content</p>
7 changes: 6 additions & 1 deletion test/execPHP.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,17 @@ const PHP = new ExecPHP()
PHP.php = phpPath

const mock_res = {
status: _status => { }
status: _status => {}
}

describe('parse from file', function () {
it('should work', async () => {
const html = await PHP.parseFile(path.join(__dirname, 'data/bonjour.php'), mock_res)
expect(html).toContain(`<p>Bonjour le monde!</p>`)
})

it('should work with relative import paths', async () => {
const html = await PHP.parseFile(path.join(__dirname, 'data/sub/content.php'), mock_res)
expect(html).toContain('<p>I am the header</p>\n<p>I am the content</p>')
})
})

0 comments on commit 9e94194

Please sign in to comment.