2011-03-23 10:51:00 +01:00
|
|
|
<?php
|
|
|
|
|
2016-10-14 03:30:05 +02:00
|
|
|
namespace SilverStripe\Admin\Tests;
|
|
|
|
|
2016-06-23 01:37:22 +02:00
|
|
|
use SilverStripe\Security\Permission;
|
2016-08-19 00:51:35 +02:00
|
|
|
use SilverStripe\Dev\FunctionalTest;
|
2016-10-14 03:30:05 +02:00
|
|
|
|
2016-12-16 05:34:21 +01:00
|
|
|
class ModelAdminTest extends FunctionalTest
|
|
|
|
{
|
|
|
|
protected static $fixture_file = 'ModelAdminTest.yml';
|
|
|
|
|
|
|
|
protected $extraDataObjects = [
|
|
|
|
ModelAdminTest\Contact::class,
|
|
|
|
ModelAdminTest\Player::class
|
|
|
|
];
|
|
|
|
|
|
|
|
protected $extraControllers = [
|
|
|
|
ModelAdminTest\ContactAdmin::class,
|
|
|
|
ModelAdminTest\PlayerAdmin::class,
|
|
|
|
];
|
|
|
|
|
|
|
|
public function testModelAdminOpens()
|
|
|
|
{
|
|
|
|
$this->autoFollowRedirection = false;
|
|
|
|
$this->logInAs('admin');
|
|
|
|
$this->assertTrue((bool)Permission::check("ADMIN"));
|
|
|
|
$this->assertEquals(200, $this->get('ContactAdmin')->getStatusCode());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testExportFieldsDefaultIsSummaryFields()
|
|
|
|
{
|
|
|
|
$admin = new ModelAdminTest\ContactAdmin();
|
|
|
|
$admin->doInit();
|
|
|
|
$this->assertEquals(
|
|
|
|
$admin->getExportFields(),
|
|
|
|
ModelAdminTest\Contact::singleton()->summaryFields()
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testExportFieldsOverloadedMethod()
|
|
|
|
{
|
|
|
|
$admin = new ModelAdminTest\PlayerAdmin();
|
|
|
|
$admin->doInit();
|
|
|
|
$this->assertEquals($admin->getExportFields(), array(
|
|
|
|
'Name' => 'Name',
|
|
|
|
'Position' => 'Position'
|
|
|
|
));
|
|
|
|
}
|
2011-03-23 10:51:00 +01:00
|
|
|
}
|