Source of file LogViewerAdminTest.php
Size: 2,968 Bytes - Last Modified: 2021-12-23T10:24:51+00:00
/var/www/docs.ssmods.com/process/src/tests/Admin/LogViewerAdminTest.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 | <?php namespace SilverLeague\LogViewer\Tests\Admin; use SilverLeague\LogViewer\Admin\LogViewerAdmin; use SilverLeague\LogViewer\Forms\GridField\GridFieldClearAllButton; use SilverStripe\Control\HTTPRequest; use SilverStripe\Dev\FunctionalTest; use SilverStripe\Forms\GridField\GridFieldAddNewButton; use SilverStripe\Forms\GridField\GridFieldPaginator; use SilverStripe\Forms\ReadonlyField; /** * @package silverstripe-logviewer * @author Robbie Averill <robbie@averill.co.nz> */ class LogViewerAdminTest extends FunctionalTest { /** * {@inheritDoc} */ protected static $fixture_file = 'LogViewerAdminTest.yml'; /** * The test subject * * @var LogViewerAdmin */ protected $logViewerAdmin; /** * {@inheritDoc} */ public function setUp() { parent::setUp(); $request = new HTTPRequest('GET', '/'); $request->setSession($this->session()); $this->logViewerAdmin = new LogViewerAdmin; $this->logViewerAdmin->setRequest($request); $this->logViewerAdmin->doInit(); } /** * Test that the log entries are returned in reverse order of creation date/time */ public function testLogsShouldBeInReverseOrder() { $entries = $this->logViewerAdmin->getList(); $this->assertSame('INFO', $entries->first()->Level); $this->assertSame('DEBUG', $entries->last()->Level); } /** * Test that the GridField "add new" button has been removed */ public function testNoAddButton() { $this->assertNull($this->getConfig()->getComponentByType(GridFieldAddNewButton::class)); } /** * Test that there's a "clear all" button */ public function testHasClearAllButton() { $this->assertInstanceOf( GridFieldClearAllButton::class, $this->getConfig()->getComponentByType(GridFieldClearAllButton::class) ); } /** * Test that the GridField has a Paginator component */ public function testHasPagination() { $this->assertInstanceOf( GridFieldPaginator::class, $this->getConfig()->getComponentByType(GridFieldPaginator::class) ); } /** * Test that the entry and level fields are displayed in the GridField, and can be exported */ public function testEntryAndLevelShouldBeInSummaryFields() { $summaryFields = $this->logViewerAdmin->getExportFields(); $this->assertContains('Entry', $summaryFields); $this->assertContains('Level', $summaryFields); } /** * Get the test GridField's config class * * @return \SilverStripe\Forms\GridField\GridFieldConfig */ protected function getConfig() { return $this->logViewerAdmin ->getEditForm() ->Fields() ->fieldByName($this->logViewerAdmin->getGridFieldName()) ->getConfig(); } } |