public function testShowDeleteButtonsWithAdminPermission() { $this->logInWithPermission('ADMIN'); $content = new CSSContentParser($this->gridField->FieldHolder()); $deleteButtons = $content->getBySelector('.gridfield-button-delete'); $this->assertEquals(3, count($deleteButtons), 'Delete buttons should show when logged in.'); }
public function testShowEditLinksWithAdminPermission() { $this->logInWithPermission('ADMIN'); $content = new CSSContentParser($this->gridField->FieldHolder()); $editLinks = $content->getBySelector('.edit-link'); $this->assertEquals(2, count($editLinks), 'Edit links should show when logged in.'); }
public function testThereIsNoPaginatorWhenOnlyOnePage() { // We set the itemsPerPage to an reasonably big number so as to avoid test broke from small changes // on the fixture YML file $total = $this->list->count(); $this->gridField->getConfig()->getComponentByType("SilverStripe\\Forms\\GridField\\GridFieldPaginator")->setItemsPerPage($total); $fieldHolder = $this->gridField->FieldHolder(); $content = new CSSContentParser($fieldHolder); // Check that there is no paginator render into the footer $this->assertEquals(0, count($content->getBySelector('.datagrid-pagination'))); // Check that there is still 'View 1 - 4 of 4' part on the left of the paginator $this->assertEquals(2, count($content->getBySelector('.pagination-records-number'))); }
/** * @covers SilverStripe\Forms\GridField\GridField::FieldHolder */ public function testCanViewOnlyOddIDs() { $this->logInWithPermission(); $list = new ArrayList(array(new GridFieldTest_Permissions(array("ID" => 1, "Email" => "*****@*****.**", 'Name' => 'Ongi Schwimmer')), new GridFieldTest_Permissions(array("ID" => 2, "Email" => "*****@*****.**", 'Name' => 'Klaus Lozenge')), new GridFieldTest_Permissions(array("ID" => 3, "Email" => "*****@*****.**", 'Name' => 'Otto Fischer')))); $config = new GridFieldConfig(); $config->addComponent(new GridFieldDataColumns()); $obj = new GridField('testfield', 'testfield', $list, $config); $form = new Form(new Controller(), 'mockform', new FieldList(array($obj)), new FieldList()); $content = new CSSContentParser($obj->FieldHolder()); $members = $content->getBySelector('.ss-gridfield-item tr'); $this->assertEquals(2, count($members)); $this->assertEquals((string) $members[0]->td[0], 'Ongi Schwimmer', 'First object Name should be Ongi Schwimmer'); $this->assertEquals((string) $members[0]->td[1], '*****@*****.**', 'First object Email should be ongi.schwimmer@example.org'); $this->assertEquals((string) $members[1]->td[0], 'Otto Fischer', 'Second object Name should be Otto Fischer'); $this->assertEquals((string) $members[1]->td[1], '*****@*****.**', 'Second object Email should be otto.fischer@example.org'); }