diff --git a/src/DataFixtures/AllFixtures.php b/src/DataFixtures/AllFixtures.php new file mode 100644 index 00000000..ab19b18c --- /dev/null +++ b/src/DataFixtures/AllFixtures.php @@ -0,0 +1,47 @@ +modify('- ' . (rand(self::TIMERANGE_BEGIN_DAYS, self::TIMERANGE_END_DAYS)) . ' days'); + $start = $this->getRandomFirstDay(); $start = $start->modify('- ' . (rand(1, 86400)) . ' seconds'); $start->setTimezone(new \DateTimeZone($user->getPreferenceValue(UserPreference::TIMEZONE, date_default_timezone_get()))); @@ -246,7 +237,7 @@ class TimesheetFixtures extends Fixture implements DependentFixtureInterface, Fi } else { // running entries should be short $newBegin = clone $entry->getBegin(); - $newBegin->setTimestamp(time())->modify('- ' . rand(10, self::TIMERANGE_RUNNING) . ' minutes'); + $newBegin->setTimestamp(time())->modify('- ' . rand(self::MIN_MINUTES_PER_ENTRY, self::MAX_MINUTES_PER_ENTRY) . ' minutes'); $entry->setBegin($newBegin); } diff --git a/src/DataFixtures/UserFixtures.php b/src/DataFixtures/UserFixtures.php index 0797275c..5fdd80f1 100644 --- a/src/DataFixtures/UserFixtures.php +++ b/src/DataFixtures/UserFixtures.php @@ -12,6 +12,7 @@ namespace App\DataFixtures; use App\Entity\User; use App\Entity\UserPreference; use Doctrine\Bundle\FixturesBundle\Fixture; +use Doctrine\Bundle\FixturesBundle\FixtureGroupInterface; use Doctrine\Persistence\ObjectManager; use Faker\Factory; use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface; @@ -25,7 +26,7 @@ use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface; * * @codeCoverageIgnore */ -class UserFixtures extends Fixture +class UserFixtures extends Fixture implements FixtureGroupInterface { public const DEFAULT_PASSWORD = 'kitten'; public const DEFAULT_API_TOKEN = 'api_kitten'; @@ -63,6 +64,11 @@ class UserFixtures extends Fixture $this->loadTestUsers($manager); } + public static function getGroups(): array + { + return ['user', 'users']; + } + /** * Default users for all test cases * diff --git a/src/Widget/Type/PaginatedWorkingTimeChart.php b/src/Widget/Type/PaginatedWorkingTimeChart.php index 3782fd09..d48b2091 100644 --- a/src/Widget/Type/PaginatedWorkingTimeChart.php +++ b/src/Widget/Type/PaginatedWorkingTimeChart.php @@ -76,10 +76,9 @@ final class PaginatedWorkingTimeChart extends SimpleWidget implements UserWidget $week = $options['week']; $weekBegin = ($dateTimeFactory->createDateTime())->setISODate($year, $week, 1)->setTime(0, 0, 0); - $weekEnd = ($dateTimeFactory->createDateTime())->setISODate($year, $week, 7)->setTime(23, 59, 59); $weekBegin = $dateTimeFactory->getStartOfWeek($weekBegin); - $weekEnd = $dateTimeFactory->getEndOfWeek($weekEnd); + $weekEnd = $dateTimeFactory->getEndOfWeek($weekBegin); $lastWeekInYear = $this->getLastWeekInYear($year); $lastWeekInLastYear = $this->getLastWeekInYear($year - 1);