added plugin screen (#671)
This commit is contained in:
@@ -29,9 +29,9 @@ class AboutControllerTest extends ControllerBaseTest
|
||||
$this->assertAccessIsGranted($client, '/admin/about');
|
||||
|
||||
$result = $client->getCrawler()->filter('div.nav-tabs-custom ul.nav.nav-tabs li');
|
||||
$this->assertEquals(3, count($result));
|
||||
$this->assertEquals(2, count($result));
|
||||
|
||||
$result = $client->getCrawler()->filter('div.nav-tabs-custom div.tab-content div.tab-pane');
|
||||
$this->assertEquals(3, count($result));
|
||||
$this->assertEquals(2, count($result));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ class CalendarControllerTest extends ControllerBaseTest
|
||||
|
||||
$crawler = $client->getCrawler();
|
||||
$calendar = $crawler->filter('div#calendar');
|
||||
$this->assertEquals(1, $calendar->count());
|
||||
}
|
||||
|
||||
public function testCalendarEntriesAction()
|
||||
|
||||
@@ -202,6 +202,23 @@ abstract class ControllerBaseTest extends WebTestCase
|
||||
$this->assertEquals($count, $node->count());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Client $client
|
||||
* @param array $buttons
|
||||
*/
|
||||
protected function assertPageActions(Client $client, array $buttons)
|
||||
{
|
||||
$node = $client->getCrawler()->filter('section.content-header div.breadcrumb div.box-tools div.btn-group a.btn');
|
||||
$this->assertEquals(count($buttons), $node->count());
|
||||
|
||||
foreach ($node->getIterator() as $element) {
|
||||
$expectedClass = str_replace('btn btn-default btn-', '', $element->getAttribute('class'));
|
||||
$this->assertArrayHasKey($expectedClass, $buttons);
|
||||
$expectedUrl = $buttons[$expectedClass];
|
||||
$this->assertEquals($expectedUrl, $element->getAttribute('href'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $role the USER role to use for the request
|
||||
* @param string $url the URL of the page displaying the initial form to submit
|
||||
|
||||
@@ -40,7 +40,6 @@ class ExportControllerTest extends ControllerBaseTest
|
||||
$em = $client->getContainer()->get('doctrine.orm.entity_manager');
|
||||
|
||||
$begin = new \DateTime('first day of this month');
|
||||
$end = new \DateTime('last day of this month');
|
||||
$fixture = new TimesheetFixtures();
|
||||
$fixture
|
||||
->setUser($this->getUserByRole($em, User::ROLE_USER))
|
||||
|
||||
48
tests/Controller/PluginControllerTest.php
Normal file
48
tests/Controller/PluginControllerTest.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Kimai time-tracking app.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace App\Tests\Controller;
|
||||
|
||||
use App\Entity\User;
|
||||
use App\Plugin\PluginManager;
|
||||
use App\Tests\Plugin\Fixtures\TestPlugin;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \App\Controller\PluginController
|
||||
* @group integration
|
||||
*/
|
||||
class PluginControllerTest extends ControllerBaseTest
|
||||
{
|
||||
public function testIsSecure()
|
||||
{
|
||||
$this->assertUrlIsSecured('/admin/plugins/');
|
||||
$this->assertUrlIsSecuredForRole(User::ROLE_ADMIN, '/admin/plugins/');
|
||||
}
|
||||
|
||||
public function testIndexAction()
|
||||
{
|
||||
$client = $this->getClientForAuthenticatedUser(User::ROLE_SUPER_ADMIN);
|
||||
$this->assertAccessIsGranted($client, '/admin/plugins/');
|
||||
$this->assertCalloutWidgetWithMessage($client, 'You have no plugin installed yet');
|
||||
$this->assertPageActions($client, ['shop' => 'https://www.kimai.org/store/']);
|
||||
}
|
||||
|
||||
public function testIndexActionWithInstalledPlugins()
|
||||
{
|
||||
$client = $this->getClientForAuthenticatedUser(User::ROLE_SUPER_ADMIN);
|
||||
|
||||
/** @var PluginManager $manager */
|
||||
$manager = self::$container->get(PluginManager::class);
|
||||
$manager->addPlugin(new TestPlugin());
|
||||
|
||||
$this->assertAccessIsGranted($client, '/admin/plugins/');
|
||||
$this->assertHasDataTable($client);
|
||||
$this->assertDataTableRowCount($client, 'datatable_plugins', 1);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user