Source of file MoreInformationPanelTest.php
Size: 2,705 Bytes - Last Modified: 2021-12-23T10:10:18+00:00
/var/www/docs.ssmods.com/process/src/tests/unit/Panels/MoreInformationPanelTest.php
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 | <?php namespace Plastyk\Dashboard\Tests; use Plastyk\Dashboard\Admin\DashboardAdmin; use Plastyk\Dashboard\Panels\MoreInformationPanel; use SilverStripe\Dev\SapphireTest; use SilverStripe\Security\Member; class MoreInformationPanelTest extends SapphireTest { protected $usesDatabase = true; protected static $fixture_file = '../../fixtures/DashboardAdminTest.yml'; public function testCreateMoreInformationPanel() { $moreInformationPanel = new MoreInformationPanel(); $this->assertNotNull($moreInformationPanel); } public function testCanView() { $moreInformationPanel = MoreInformationPanel::singleton(); $this->assertTrue($moreInformationPanel->canView()); $nonPermittedUser = $this->objFromFixture(Member::class, 'user2'); $this->logInAs($nonPermittedUser); $this->assertFalse($moreInformationPanel->canView()); } public function testGetData() { DashboardAdmin::config()->set('contact_email', 'roxane.gay@gmail.com'); DashboardAdmin::config()->set('contact_name', 'Roxane Gay'); $moreInformationPanel = MoreInformationPanel::singleton(); $data = $moreInformationPanel->getData(); $this->assertTrue(isset($data['ContactEmail'])); $this->assertEquals('roxane.gay@gmail.com', $data['ContactEmail']); $this->assertTrue(isset($data['ContactName'])); $this->assertEquals('Roxane Gay', $data['ContactName']); DashboardAdmin::config()->remove('contact_email'); DashboardAdmin::config()->remove('contact_name'); $data = $moreInformationPanel->getData(); $this->assertTrue(isset($data['ContactEmail'])); $this->assertFalse($data['ContactEmail']); $this->assertTrue(isset($data['ContactName'])); $this->assertEquals('your web developer', $data['ContactName']); } public function testGetContent() { DashboardAdmin::config()->set('contact_email', 'roxane.gay@gmail.com'); DashboardAdmin::config()->set('contact_name', 'Roxane Gay'); $moreInformationPanel = MoreInformationPanel::singleton(); $content = $moreInformationPanel->getContent(); $this->assertContains('Custom dashboard panels are available.', $content->value); $this->assertContains('mailto:roxane.gay@gmail.com', $content->value); DashboardAdmin::config()->remove('contact_email'); DashboardAdmin::config()->remove('contact_name'); $content = $moreInformationPanel->getContent(); $this->assertContains( 'Contact your web developer if you would like to discuss.', $content->value ); } } |