def test_new(self): php = PHP() dt = php.new('DateTime') ts = dt.getTimestamp() php.echo(ts) output = str(php) self.assertAlmostEquals(int(output), time(), delta=10)
def test_dyn_getitem(self): php = PHP() array_params = range(self.TEST_RANGE) array = php.array(*array_params) php.shuffle(array) php.echo(array[array[0]]) self.assertIn(int(str(php)), array_params)
def test_dict(self): php = PHP() values = php.array_values(self.TEST_DICT) php.sort(values) php.echo(php.implode(',', values)) expected = ','.join(sorted(self.TEST_DICT.itervalues())) self.assertEquals(str(php), expected)
def test_add(self): php = PHP() array = php.range(1, self.TEST_RANGE) php.echo(php.count(array) + self.TEST_VALUE) self.assertEquals(str(php), str(self.TEST_VALUE + self.TEST_RANGE))
def test_getitem(self): php = PHP() array_params = range(self.TEST_RANGE) array = php.array(*array_params) php.echo(array[0]) self.assertEquals(str(php), str(array_params[0]))
def test_list(self): php = PHP() php.echo(php.count(range(self.TEST_RANGE))) output = str(php) self.assertEquals(output, str(self.TEST_RANGE))
def test_deep_compose(self): php = PHP() php.echo(php.strlen(php.strrev(self.TEST_STRING))) output = str(php) self.assertEquals(output, str(len(self.TEST_STRING)))
def test_echo(self): php = PHP() php.echo(self.TEST_STRING) self.assertEquals(str(php), self.TEST_STRING)