Skip to content

Commit

Permalink
Merge pull request #3 from yoloseem/travisci
Browse files Browse the repository at this point in the history
Add test and set Travis CI.
  • Loading branch information
leekchan committed Jan 27, 2014
2 parents 87ecdd7 + 1e5fd64 commit 00e1e50
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 1 deletion.
11 changes: 11 additions & 0 deletions .travis.yml
@@ -0,0 +1,11 @@
language: python
python:
- "2.7"
before_script:
- sudo apt-get update
- sudo apt-get install php5-cli
install:
- pip install pytest
- python setup.py install
script:
- py.test
6 changes: 5 additions & 1 deletion phpy/php.py
Expand Up @@ -12,8 +12,12 @@ def __init__(self, file_path):

def __quote(self, arguments):
for arg in arguments:
if type(arg) in (str, unicode):
if isinstance(arg, basestring):
if isinstance(arg, unicode):
arg = arg.encode('utf-8')
yield '\'%s\'' % arg
elif arg is None:
yield 'NULL'
else:
yield str(arg)

Expand Down
10 changes: 10 additions & 0 deletions tests/test.php
@@ -0,0 +1,10 @@
<?php
function mapping($foo, $bar, $baz) {
$rv = array(
"foo" => $foo,
"bar" => $bar,
"baz" => $baz
);
echo json_encode($rv);
}
?>
22 changes: 22 additions & 0 deletions tests/test_phpy.py
@@ -0,0 +1,22 @@
# encoding: utf-8
import os.path
import pytest
from phpy import PHP


test_php_path = os.path.join(os.path.dirname(__file__), 'test.php')


@pytest.mark.parametrize(('foo', 'bar', 'baz'), [
(1, 2, 3),
(0.0, 1.1, 2.2),
('foo', 'bar', 'baz'),
(u'가', u'나', u'다'),
(None, None, None),
])
def test_get_dict(foo, bar, baz):
php = PHP(test_php_path)
assert (
php.get_dict('mapping', [foo, bar, baz]) ==
dict(foo=foo, bar=bar, baz=baz)
)

0 comments on commit 00e1e50

Please sign in to comment.