Skip to content

Commit b05c754

Browse files
committed
adding test for co-dependent classes
currently failing, to-fix
1 parent 58fef19 commit b05c754

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

tests/integration/src/classes.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,21 @@ fn integrate_bar_extends_foo(module: &mut Module, foo_class: StateClass<Foo>) {
229229
module.add_class(cls);
230230
}
231231

232+
fn integrate_dependent_classes(module: &mut Module) {
233+
let mut a_cls = ClassEntity::new(r"IntegrationTest\Dependency\A");
234+
let mut b_cls = ClassEntity::new(r"IntegrationTest\Dependency\B");
235+
236+
a_cls.add_static_method("createB", Visibility::Public, |_| {
237+
let b = b_cls.init_object()?;
238+
Ok::<_, phper::Error>(b)
239+
});
240+
241+
b_cls.add_static_method("createA", Visibility::Public, |_| {
242+
let a = a_cls.init_object()?;
243+
Ok::<_, phper::Error>(a)
244+
});
245+
}
246+
232247
#[cfg(phper_major_version = "8")]
233248
fn integrate_stringable(module: &mut Module) {
234249
use phper::{functions::ReturnType, types::ReturnTypeHint};

tests/integration/tests/php/classes.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,3 +105,9 @@ class Foo2 extends IntegrationTest\Foo {}
105105
$bar = new \IntegrationTest\BarExtendsFoo; //Bar should extend Foo
106106
$reflection = new ReflectionClass($bar);
107107
assert_true($reflection->isSubclassOf(IntegrationTest\Foo::class));
108+
109+
// Test co-dependent classes
110+
$b = IntegrationTest\Dependency\A::createB();
111+
assert_true($b instanceof IntegrationTest\Dependency\B);
112+
$a = IntegrationTest\Dependency\B::createA();
113+
assert_true($a instanceof IntegrationTest\Dependency\A);

0 commit comments

Comments
 (0)