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