Files
phpy/tests/test_object.py
tianfenghan d4bf7a56e1 skip tests
2023-12-20 20:11:24 +08:00

46 lines
968 B
Python

import os
import pytest
import phpy
def test_new_object():
c = phpy.Class('PhpyObject')
uuid = phpy.call('uniqid')
o = c.new(uuid)
uuid2 = o.call('test')
assert uuid2 == uuid
def test_new_object_not_exists():
try:
c = phpy.Class('NotFound')
except TypeError as e:
var = str(e).find('Class "NotFound" not found')
assert var != -1
def test_property():
o = phpy.Object('stdClass')
rdata = phpy.call('uniqid')
o.set("value", rdata)
assert o.get("value") == rdata
def test_object():
if os.environ.get('IN_CI'):
return
o = phpy.Object('redis')
assert o.call('connect', '127.0.0.1', 6379)
rdata = phpy.call('uniqid')
assert o.call('set', 'key', rdata)
assert o.call('get', 'key') == rdata
def test_return_object():
if os.environ.get('IN_CI'):
return
o = phpy.call('curl_init')
_type = phpy.call('get_class', o)
assert _type == 'CurlHandle'