public function testrootFieldList() { /* Given a nested set of FormField, CompositeField, and FieldList objects */ $FieldList = new FieldList($root = new TabSet("Root", $main = new Tab("Main", $a = new TextField("A"), $b = new TextField("B")))); /* rootFieldList() should always evaluate to the same object: the topmost FieldList */ $this->assertSame($FieldList, $FieldList->rootFieldList()); $this->assertSame($FieldList, $root->rootFieldList()); $this->assertSame($FieldList, $main->rootFieldList()); $this->assertSame($FieldList, $a->rootFieldList()); $this->assertSame($FieldList, $b->rootFieldList()); /* If we push additional fields, they should also have the same rootFieldList() */ $root->push($other = new Tab("Other")); $other->push($c = new TextField("C")); $root->push($third = new Tab("Third", $d = new TextField("D"))); $this->assertSame($FieldList, $other->rootFieldList()); $this->assertSame($FieldList, $third->rootFieldList()); $this->assertSame($FieldList, $c->rootFieldList()); $this->assertSame($FieldList, $d->rootFieldList()); }