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