Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
horitaku1124 committed Apr 6, 2019
1 parent 83ce305 commit 14fd2a3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## PHP4/5 to PHP7

[![Build Status](https://dev.azure.com/newwoory/PHP-Converter/_apis/build/status/horitaku1124.php-converter?branchName=master)](https://dev.azure.com/newwoory/PHP-Converter/_build/latest?definitionId=3&branchName=master)

```
node convert.js foo.php ; => dist/foo.php
```
Expand Down
18 changes: 14 additions & 4 deletions test/unit-test-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,20 @@ const convertTo7 = (code) => {
return codes.map(c => c.value).join("");
};

describe('PHP4 code', () => {
it('will be translated to PHP7 code', () => {
let c7 = convertTo7("<?php\n$a = Split('A');");
console.log(c7);
describe('PHP converter', () => {
it('change split to explode or preg_split', () => {
let c7;
c7 = convertTo7("<?php\n$a = Split('A');");
assert.equal(c7, "<?php\n$a = explode(\"A\");");

c7 = convertTo7("<?php\n$a = Split('\\d');");
assert.equal(c7, "<?php\n$a = preg_split('/\\d/');");
});
it('change old array syntax to []', () => {
let c7;
c7 = convertTo7("<?php\n$a = Array();");
assert.equal(c7, "<?php\n$a = [];");
// c7 = convertTo7("<?php\n$a = array(1,2,3,4,5);");
// assert.equal(c7, "<?php\n$a = [1,2,3,4,5];");
});
});

0 comments on commit 14fd2a3

Please sign in to comment.