function testSecondPageOfPaginatedSourceItemGeneration() { /* With pagination enabled, only the first page of items should be shown */ $table = new TableListField("Tester", "TableListFieldTest_Obj", array("A" => "Col A", "B" => "Col B", "C" => "Col C", "D" => "Col D", "E" => "Col E")); // A TableListField must be inside a form for its links to be generated $form = new Form(new TableListFieldTest_TestController(), "TestForm", new FieldSet($table), new FieldSet()); $table->ShowPagination = true; $table->PageSize = 2; $_REQUEST['ctf']['Tester']['start'] = 2; $items = $table->sourceItems(); $this->assertNotNull($items); $itemMap = $items->toDropdownMap("ID", "A"); $this->assertEquals(array(3 => "a3", 4 => "a4"), $itemMap); }
public function testSecondPageOfPaginatedSourceItemGeneration() { $item1 = $this->objFromFixture('TableListFieldTest_Obj', 'one'); $item2 = $this->objFromFixture('TableListFieldTest_Obj', 'two'); $item3 = $this->objFromFixture('TableListFieldTest_Obj', 'three'); $item4 = $this->objFromFixture('TableListFieldTest_Obj', 'four'); $item5 = $this->objFromFixture('TableListFieldTest_Obj', 'five'); // With pagination enabled, only the first page of items should be shown $table = new TableListField("Tester", "TableListFieldTest_Obj", array("A" => "Col A", "B" => "Col B", "C" => "Col C", "D" => "Col D", "E" => "Col E")); // A TableListField must be inside a form for its links to be generated $form = new Form(new TableListFieldTest_TestController(), "TestForm", new FieldList($table), new FieldList()); $table->ShowPagination = true; $table->PageSize = 2; $_REQUEST['ctf']['Tester']['start'] = 2; $items = $table->sourceItems(); $this->assertNotNull($items); $itemMap = $items->map("ID", "A"); $this->assertEquals(array($item3->ID => "a3", $item4->ID => "a4"), $itemMap->toArray()); }