user-profile - sidebar links and language settings (#369)
This commit is contained in:
@@ -18,6 +18,11 @@ use App\Tests\DataFixtures\TimesheetFixtures;
|
||||
*/
|
||||
class ActivityControllerTest extends ControllerBaseTest
|
||||
{
|
||||
public function testIsSecure()
|
||||
{
|
||||
$this->assertUrlIsSecured('/activities/recent');
|
||||
}
|
||||
|
||||
public function testRecentActivitiesAction()
|
||||
{
|
||||
$client = $this->getClientForAuthenticatedUser(User::ROLE_USER);
|
||||
|
||||
53
tests/Controller/HomepageControllerTest.php
Normal file
53
tests/Controller/HomepageControllerTest.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?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\Entity\UserPreference;
|
||||
use App\Form\Type\LanguageType;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \App\Controller\HomepageController
|
||||
* @group integration
|
||||
*/
|
||||
class HomepageControllerTest extends ControllerBaseTest
|
||||
{
|
||||
public function testIsSecure()
|
||||
{
|
||||
$this->assertUrlIsSecured('/homepage');
|
||||
}
|
||||
|
||||
public function testIndexAction()
|
||||
{
|
||||
$client = $this->getClientForAuthenticatedUser(User::ROLE_USER);
|
||||
$this->request($client, '/homepage');
|
||||
$this->assertIsRedirect($client, '/en/timesheet/');
|
||||
}
|
||||
|
||||
public function testIndexActionWithChangedLanguage()
|
||||
{
|
||||
$client = $this->getClientForAuthenticatedUser(User::ROLE_USER);
|
||||
|
||||
$em = $client->getContainer()->get('doctrine.orm.entity_manager');
|
||||
$user = $this->getUserByRole($em, User::ROLE_USER);
|
||||
|
||||
$pref = (new UserPreference())
|
||||
->setName('language')
|
||||
->setValue('ar')
|
||||
->setType(LanguageType::class);
|
||||
|
||||
$user->addPreference($pref);
|
||||
|
||||
$em->persist($pref);
|
||||
|
||||
$this->request($client, '/homepage');
|
||||
$this->assertIsRedirect($client, '/ar/timesheet/');
|
||||
}
|
||||
}
|
||||
@@ -230,6 +230,8 @@ class ProfileControllerTest extends ControllerBaseTest
|
||||
'user_preferences_form' => [
|
||||
'preferences' => [
|
||||
['name' => UserPreference::HOURLY_RATE, 'value' => 37],
|
||||
// ['name' => 'timezone', 'value' => 'America/Creston'],
|
||||
['name' => 'language', 'value' => 'ar'],
|
||||
['name' => UserPreference::SKIN, 'value' => 'blue'],
|
||||
['name' => 'theme.fixed_layout', 'value' => false],
|
||||
['name' => 'theme.boxed_layout', 'value' => true],
|
||||
@@ -250,6 +252,8 @@ class ProfileControllerTest extends ControllerBaseTest
|
||||
$user = $this->getUserByRole($em, User::ROLE_USER);
|
||||
|
||||
$this->assertEquals(37, $user->getPreferenceValue(UserPreference::HOURLY_RATE));
|
||||
//$this->assertEquals('', $user->getPreferenceValue('America/Creston'));
|
||||
$this->assertEquals('ar', $user->getPreferenceValue('language'));
|
||||
$this->assertEquals('blue', $user->getPreferenceValue(UserPreference::SKIN));
|
||||
$this->assertEquals(false, $user->getPreferenceValue('theme.fixed_layout'));
|
||||
$this->assertEquals(true, $user->getPreferenceValue('theme.boxed_layout'));
|
||||
|
||||
@@ -31,6 +31,9 @@ class SidebarControllerTest extends ControllerBaseTest
|
||||
|
||||
$this->assertContains('<ul class="control-sidebar-menu">', $content);
|
||||
$this->assertContains('<a href="/en/profile/' . $user->getUsername() . '">', $content);
|
||||
$this->assertContains('<select class="pull-right" onchange="window.location.href = this.options[this.selectedIndex].value;">', $content);
|
||||
$this->assertContains('<a href="/en/profile/' . $user->getUsername() . '/edit">', $content);
|
||||
$this->assertContains('<a href="/en/profile/' . $user->getUsername() . '/prefs">', $content);
|
||||
$this->assertContains('<a href="/en/help/">', $content);
|
||||
$this->assertContains('<a href="/en/logout">', $content);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -232,8 +232,12 @@ class TimesheetControllerTest extends ControllerBaseTest
|
||||
$this->assertInstanceOf(\DateTime::class, $timesheet->getBegin());
|
||||
$this->assertInstanceOf(\DateTime::class, $timesheet->getEnd());
|
||||
$this->assertEquals(50, $timesheet->getRate());
|
||||
$this->assertEquals('2018-08-02T20:00:00+00:00', $timesheet->getBegin()->format(\DateTime::ATOM));
|
||||
$this->assertEquals('2018-08-02T20:30:00+00:00', $timesheet->getEnd()->format(\DateTime::ATOM));
|
||||
|
||||
$expected = new \DateTime('2018-08-02T20:00:00');
|
||||
$this->assertEquals($expected->format(\DateTime::ATOM), $timesheet->getBegin()->format(\DateTime::ATOM));
|
||||
|
||||
$expected = new \DateTime('2018-08-02T20:30:00');
|
||||
$this->assertEquals($expected->format(\DateTime::ATOM), $timesheet->getEnd()->format(\DateTime::ATOM));
|
||||
}
|
||||
|
||||
public function testCreateActionWithBeginAndEndValues()
|
||||
@@ -260,8 +264,12 @@ class TimesheetControllerTest extends ControllerBaseTest
|
||||
$this->assertInstanceOf(\DateTime::class, $timesheet->getBegin());
|
||||
$this->assertInstanceOf(\DateTime::class, $timesheet->getEnd());
|
||||
$this->assertEquals(800, $timesheet->getRate());
|
||||
$this->assertEquals('2018-08-02T10:00:00+00:00', $timesheet->getBegin()->format(\DateTime::ATOM));
|
||||
$this->assertEquals('2018-08-02T18:00:00+00:00', $timesheet->getEnd()->format(\DateTime::ATOM));
|
||||
|
||||
$expected = new \DateTime('2018-08-02T10:00:00');
|
||||
$this->assertEquals($expected->format(\DateTime::ATOM), $timesheet->getBegin()->format(\DateTime::ATOM));
|
||||
|
||||
$expected = new \DateTime('2018-08-02T18:00:00');
|
||||
$this->assertEquals($expected->format(\DateTime::ATOM), $timesheet->getEnd()->format(\DateTime::ATOM));
|
||||
}
|
||||
|
||||
public function testEditAction()
|
||||
|
||||
Reference in New Issue
Block a user