refactored search with free search term support (#1064)
This commit is contained in:
@@ -19,20 +19,37 @@ use Faker\Factory;
|
||||
/**
|
||||
* Defines the sample data to load in during controller tests.
|
||||
*/
|
||||
class ActivityFixtures extends Fixture
|
||||
final class ActivityFixtures extends Fixture
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $amount = 0;
|
||||
private $amount = 0;
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $isGlobal = false;
|
||||
private $isGlobal = false;
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $isVisible = null;
|
||||
private $isVisible = null;
|
||||
/**
|
||||
* @var callable
|
||||
*/
|
||||
private $callback;
|
||||
|
||||
/**
|
||||
* Will be called prior to persisting the object.
|
||||
*
|
||||
* @param callable $callback
|
||||
* @return ActivityFixtures
|
||||
*/
|
||||
public function setCallback(callable $callback): ActivityFixtures
|
||||
{
|
||||
$this->callback = $callback;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
@@ -42,33 +59,21 @@ class ActivityFixtures extends Fixture
|
||||
return $this->amount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $global
|
||||
* @return $this
|
||||
*/
|
||||
public function setIsGlobal(bool $global)
|
||||
public function setIsGlobal(bool $global): ActivityFixtures
|
||||
{
|
||||
$this->isGlobal = $global;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $visible
|
||||
* @return $this
|
||||
*/
|
||||
public function setIsVisible(bool $visible)
|
||||
public function setIsVisible(bool $visible): ActivityFixtures
|
||||
{
|
||||
$this->isVisible = $visible;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $amount
|
||||
* @return ActivityFixtures
|
||||
*/
|
||||
public function setAmount(int $amount)
|
||||
public function setAmount(int $amount): ActivityFixtures
|
||||
{
|
||||
$this->amount = $amount;
|
||||
|
||||
@@ -93,15 +98,18 @@ class ActivityFixtures extends Fixture
|
||||
if (null !== $this->isVisible) {
|
||||
$visible = $this->isVisible;
|
||||
}
|
||||
$entity = new Activity();
|
||||
$entity
|
||||
$activity = new Activity();
|
||||
$activity
|
||||
->setProject($project)
|
||||
->setName($faker->bs . ($visible ? '' : ' (x)'))
|
||||
->setComment($faker->text)
|
||||
->setVisible($visible)
|
||||
;
|
||||
|
||||
$manager->persist($entity);
|
||||
if (null !== $this->callback) {
|
||||
call_user_func($this->callback, $activity);
|
||||
}
|
||||
$manager->persist($activity);
|
||||
}
|
||||
|
||||
$manager->flush();
|
||||
|
||||
@@ -18,41 +18,47 @@ use Faker\Factory;
|
||||
/**
|
||||
* Defines the sample data to load in during controller tests.
|
||||
*/
|
||||
class CustomerFixtures extends Fixture
|
||||
final class CustomerFixtures extends Fixture
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $amount = 0;
|
||||
private $amount = 0;
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $isVisible = null;
|
||||
private $isVisible = null;
|
||||
/**
|
||||
* @var callable
|
||||
*/
|
||||
private $callback;
|
||||
|
||||
/**
|
||||
* @return int
|
||||
* Will be called prior to persisting the object.
|
||||
*
|
||||
* @param callable $callback
|
||||
* @return CustomerFixtures
|
||||
*/
|
||||
public function setCallback(callable $callback): CustomerFixtures
|
||||
{
|
||||
$this->callback = $callback;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getAmount(): int
|
||||
{
|
||||
return $this->amount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $amount
|
||||
* @return CustomerFixtures
|
||||
*/
|
||||
public function setAmount(int $amount)
|
||||
public function setAmount(int $amount): CustomerFixtures
|
||||
{
|
||||
$this->amount = $amount;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $visible
|
||||
* @return $this
|
||||
*/
|
||||
public function setIsVisible(bool $visible)
|
||||
public function setIsVisible(bool $visible): CustomerFixtures
|
||||
{
|
||||
$this->isVisible = $visible;
|
||||
|
||||
@@ -71,8 +77,8 @@ class CustomerFixtures extends Fixture
|
||||
if (null !== $this->isVisible) {
|
||||
$visible = $this->isVisible;
|
||||
}
|
||||
$entity = new Customer();
|
||||
$entity
|
||||
$customer = new Customer();
|
||||
$customer
|
||||
->setCurrency($faker->currencyCode)
|
||||
->setName($faker->company . ($visible ? '' : ' (x)'))
|
||||
->setAddress($faker->address)
|
||||
@@ -83,7 +89,10 @@ class CustomerFixtures extends Fixture
|
||||
->setVisible($visible)
|
||||
;
|
||||
|
||||
$manager->persist($entity);
|
||||
if (null !== $this->callback) {
|
||||
call_user_func($this->callback, $customer);
|
||||
}
|
||||
$manager->persist($customer);
|
||||
}
|
||||
|
||||
$manager->flush();
|
||||
|
||||
@@ -19,47 +19,53 @@ use Faker\Factory;
|
||||
/**
|
||||
* Defines the sample data to load in during controller tests.
|
||||
*/
|
||||
class ProjectFixtures extends Fixture
|
||||
final class ProjectFixtures extends Fixture
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $amount = 0;
|
||||
private $amount = 0;
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $isVisible = null;
|
||||
|
||||
private $isVisible = null;
|
||||
/**
|
||||
* @return int
|
||||
* @var callable
|
||||
*/
|
||||
private $callback;
|
||||
|
||||
public function getAmount(): int
|
||||
{
|
||||
return $this->amount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $amount
|
||||
* @return ProjectFixtures
|
||||
*/
|
||||
public function setAmount(int $amount)
|
||||
public function setAmount(int $amount): ProjectFixtures
|
||||
{
|
||||
$this->amount = $amount;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $visible
|
||||
* @return $this
|
||||
*/
|
||||
public function setIsVisible(bool $visible)
|
||||
public function setIsVisible(bool $visible): ProjectFixtures
|
||||
{
|
||||
$this->isVisible = $visible;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Will be called prior to persisting the object.
|
||||
*
|
||||
* @param callable $callback
|
||||
* @return ProjectFixtures
|
||||
*/
|
||||
public function setCallback(callable $callback): ProjectFixtures
|
||||
{
|
||||
$this->callback = $callback;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
@@ -73,8 +79,8 @@ class ProjectFixtures extends Fixture
|
||||
if (null !== $this->isVisible) {
|
||||
$visible = $this->isVisible;
|
||||
}
|
||||
$entity = new Project();
|
||||
$entity
|
||||
$project = new Project();
|
||||
$project
|
||||
->setName($faker->catchPhrase . ($visible ? '' : ' (x)'))
|
||||
->setBudget(rand(0, 10000))
|
||||
->setComment($faker->text)
|
||||
@@ -82,7 +88,10 @@ class ProjectFixtures extends Fixture
|
||||
->setVisible($visible)
|
||||
;
|
||||
|
||||
$manager->persist($entity);
|
||||
if (null !== $this->callback) {
|
||||
call_user_func($this->callback, $project);
|
||||
}
|
||||
$manager->persist($project);
|
||||
}
|
||||
|
||||
$manager->flush();
|
||||
|
||||
@@ -16,17 +16,34 @@ use Doctrine\Common\Persistence\ObjectManager;
|
||||
/**
|
||||
* Defines the sample data to load in during controller tests.
|
||||
*/
|
||||
class TagFixtures extends Fixture
|
||||
final class TagFixtures extends Fixture
|
||||
{
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
protected $tagArray = [];
|
||||
private $tagArray = [];
|
||||
/**
|
||||
* @var callable
|
||||
*/
|
||||
private $callback;
|
||||
|
||||
/**
|
||||
* Will be called prior to persisting the object.
|
||||
*
|
||||
* @param callable $callback
|
||||
* @return TagFixtures
|
||||
*/
|
||||
public function setCallback(callable $callback): TagFixtures
|
||||
{
|
||||
$this->callback = $callback;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public function getTagArray()
|
||||
public function getTagArray(): array
|
||||
{
|
||||
return $this->tagArray;
|
||||
}
|
||||
@@ -35,7 +52,7 @@ class TagFixtures extends Fixture
|
||||
* @param string[] $tagArray
|
||||
* @return TagFixtures
|
||||
*/
|
||||
public function setTagArray(array $tagArray)
|
||||
public function setTagArray(array $tagArray): TagFixtures
|
||||
{
|
||||
$this->tagArray = $tagArray;
|
||||
|
||||
@@ -48,13 +65,17 @@ class TagFixtures extends Fixture
|
||||
public function load(ObjectManager $manager)
|
||||
{
|
||||
foreach ($this->getTagArray() as $tagName) {
|
||||
$entry = $this->createTagEntry($tagName);
|
||||
$manager->persist($entry);
|
||||
$tag = $this->createTagEntry($tagName);
|
||||
|
||||
if (null !== $this->callback) {
|
||||
call_user_func($this->callback, $tag);
|
||||
}
|
||||
$manager->persist($tag);
|
||||
}
|
||||
$manager->flush();
|
||||
}
|
||||
|
||||
protected function createTagEntry(string $tagName): Tag
|
||||
private function createTagEntry(string $tagName): Tag
|
||||
{
|
||||
$tagObject = new Tag();
|
||||
$tagObject->setName($tagName);
|
||||
|
||||
@@ -19,33 +19,54 @@ use Faker\Factory;
|
||||
/**
|
||||
* Defines the sample data to load in during controller tests.
|
||||
*/
|
||||
class TeamFixtures extends Fixture
|
||||
final class TeamFixtures extends Fixture
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $amount = 0;
|
||||
private $amount = 0;
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $addCustomer = true;
|
||||
private $addCustomer = true;
|
||||
/**
|
||||
* @var User[]
|
||||
*/
|
||||
protected $skipUser = [];
|
||||
private $skipUser = [];
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $addUser = true;
|
||||
private $addUser = true;
|
||||
/**
|
||||
* @var callable
|
||||
*/
|
||||
private $callback;
|
||||
|
||||
public function setAddCustomer(bool $useCustomer)
|
||||
/**
|
||||
* Will be called prior to persisting the object.
|
||||
*
|
||||
* @param callable $callback
|
||||
* @return TeamFixtures
|
||||
*/
|
||||
public function setCallback(callable $callback): TeamFixtures
|
||||
{
|
||||
$this->addCustomer = $useCustomer;
|
||||
$this->callback = $callback;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setAddUser(bool $useUser)
|
||||
public function setAddCustomer(bool $useCustomer): TeamFixtures
|
||||
{
|
||||
$this->addCustomer = $useCustomer;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setAddUser(bool $useUser): TeamFixtures
|
||||
{
|
||||
$this->addUser = $useUser;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getAmount(): int
|
||||
@@ -60,9 +81,11 @@ class TeamFixtures extends Fixture
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addUserToIgnore(User $user)
|
||||
public function addUserToIgnore(User $user): TeamFixtures
|
||||
{
|
||||
$this->skipUser[] = $user;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -83,8 +106,8 @@ class TeamFixtures extends Fixture
|
||||
}
|
||||
}
|
||||
|
||||
$entity = new Team();
|
||||
$entity
|
||||
$team = new Team();
|
||||
$team
|
||||
->setName($faker->name)
|
||||
->setTeamLead($lead)
|
||||
;
|
||||
@@ -97,14 +120,17 @@ class TeamFixtures extends Fixture
|
||||
$userToAdd = $tmp;
|
||||
}
|
||||
}
|
||||
$entity->addUser($userToAdd);
|
||||
$team->addUser($userToAdd);
|
||||
}
|
||||
|
||||
if ($this->addCustomer) {
|
||||
$entity->addCustomer($customer[array_rand($customer)]);
|
||||
$team->addCustomer($customer[array_rand($customer)]);
|
||||
}
|
||||
|
||||
$manager->persist($entity);
|
||||
if (null !== $this->callback) {
|
||||
call_user_func($this->callback, $team);
|
||||
}
|
||||
$manager->persist($team);
|
||||
}
|
||||
|
||||
$manager->flush();
|
||||
@@ -114,7 +140,7 @@ class TeamFixtures extends Fixture
|
||||
* @param ObjectManager $manager
|
||||
* @return Customer[]
|
||||
*/
|
||||
protected function getAllCustomers(ObjectManager $manager)
|
||||
private function getAllCustomers(ObjectManager $manager)
|
||||
{
|
||||
$all = [];
|
||||
/* @var Customer[] $entries */
|
||||
@@ -130,7 +156,7 @@ class TeamFixtures extends Fixture
|
||||
* @param ObjectManager $manager
|
||||
* @return User[]
|
||||
*/
|
||||
protected function getAllUsers(ObjectManager $manager)
|
||||
private function getAllUsers(ObjectManager $manager)
|
||||
{
|
||||
$all = [];
|
||||
/* @var User[] $entries */
|
||||
|
||||
@@ -23,95 +23,83 @@ use Faker\Factory;
|
||||
/**
|
||||
* Defines the sample data to load in during controller tests.
|
||||
*/
|
||||
class TimesheetFixtures extends Fixture
|
||||
final class TimesheetFixtures extends Fixture
|
||||
{
|
||||
/**
|
||||
* @var User
|
||||
*/
|
||||
protected $user;
|
||||
private $user;
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $amount = 0;
|
||||
private $amount = 0;
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $running = 0;
|
||||
private $running = 0;
|
||||
/**
|
||||
* @var Activity[]
|
||||
*/
|
||||
protected $activities = [];
|
||||
private $activities = [];
|
||||
/**
|
||||
* @var Project[]
|
||||
*/
|
||||
protected $projects = [];
|
||||
private $projects = [];
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $startDate = '2018-04-01';
|
||||
private $startDate = '2018-04-01';
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $fixedRate = false;
|
||||
private $fixedRate = false;
|
||||
/**
|
||||
* @var callable
|
||||
*/
|
||||
private $callback;
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $hourlyRate = false;
|
||||
private $hourlyRate = false;
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $allowEmptyDescriptions = true;
|
||||
private $allowEmptyDescriptions = true;
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $exported = false;
|
||||
private $exported = false;
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $useTags = false;
|
||||
private $useTags = false;
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $tags = [];
|
||||
private $tags = [];
|
||||
|
||||
/**
|
||||
* @param bool $allowEmptyDescriptions
|
||||
* @return TimesheetFixtures
|
||||
*/
|
||||
public function setAllowEmptyDescriptions(bool $allowEmptyDescriptions)
|
||||
public function setAllowEmptyDescriptions(bool $allowEmptyDescriptions): TimesheetFixtures
|
||||
{
|
||||
$this->allowEmptyDescriptions = $allowEmptyDescriptions;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $exported
|
||||
* @return TimesheetFixtures
|
||||
*/
|
||||
public function setExported(bool $exported)
|
||||
public function setExported(bool $exported): TimesheetFixtures
|
||||
{
|
||||
$this->exported = $exported;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $fixedRate
|
||||
* @return TimesheetFixtures
|
||||
*/
|
||||
public function setFixedRate(bool $fixedRate)
|
||||
public function setFixedRate(bool $fixedRate): TimesheetFixtures
|
||||
{
|
||||
$this->fixedRate = $fixedRate;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $hourlyRate
|
||||
* @return TimesheetFixtures
|
||||
*/
|
||||
public function setHourlyRate(bool $hourlyRate)
|
||||
public function setHourlyRate(bool $hourlyRate): TimesheetFixtures
|
||||
{
|
||||
$this->hourlyRate = $hourlyRate;
|
||||
|
||||
@@ -122,7 +110,7 @@ class TimesheetFixtures extends Fixture
|
||||
* @param string|\DateTime $date
|
||||
* @return TimesheetFixtures
|
||||
*/
|
||||
public function setStartDate($date)
|
||||
public function setStartDate($date): TimesheetFixtures
|
||||
{
|
||||
if ($date instanceof \DateTime) {
|
||||
$date = $date->format('Y-m-d');
|
||||
@@ -132,33 +120,21 @@ class TimesheetFixtures extends Fixture
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $amount
|
||||
* @return $this
|
||||
*/
|
||||
public function setAmountRunning($amount)
|
||||
public function setAmountRunning(int $amount): TimesheetFixtures
|
||||
{
|
||||
$this->running = $amount;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $amount
|
||||
* @return $this
|
||||
*/
|
||||
public function setAmount($amount)
|
||||
public function setAmount(int $amount): TimesheetFixtures
|
||||
{
|
||||
$this->amount = $amount;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param User $user
|
||||
* @return $this
|
||||
*/
|
||||
public function setUser(User $user)
|
||||
public function setUser(User $user): TimesheetFixtures
|
||||
{
|
||||
$this->user = $user;
|
||||
|
||||
@@ -167,9 +143,9 @@ class TimesheetFixtures extends Fixture
|
||||
|
||||
/**
|
||||
* @param Activity[] $activities
|
||||
* @return $this
|
||||
* @return TimesheetFixtures
|
||||
*/
|
||||
public function setActivities(array $activities)
|
||||
public function setActivities(array $activities): TimesheetFixtures
|
||||
{
|
||||
$this->activities = $activities;
|
||||
|
||||
@@ -178,20 +154,16 @@ class TimesheetFixtures extends Fixture
|
||||
|
||||
/**
|
||||
* @param Project[] $projects
|
||||
* @return $this
|
||||
* @return TimesheetFixtures
|
||||
*/
|
||||
public function setProjects(array $projects)
|
||||
public function setProjects(array $projects): TimesheetFixtures
|
||||
{
|
||||
$this->projects = $projects;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $useTags
|
||||
* @return TimesheetFixtures
|
||||
*/
|
||||
public function setUseTags(bool $useTags)
|
||||
public function setUseTags(bool $useTags): TimesheetFixtures
|
||||
{
|
||||
$this->useTags = $useTags;
|
||||
|
||||
@@ -199,16 +171,29 @@ class TimesheetFixtures extends Fixture
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $tags
|
||||
* @param string[] $tags
|
||||
* @return TimesheetFixtures
|
||||
*/
|
||||
public function setTags(array $tags)
|
||||
public function setTags(array $tags): TimesheetFixtures
|
||||
{
|
||||
$this->tags = $tags;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Will be called prior to persisting the object.
|
||||
*
|
||||
* @param callable $callback
|
||||
* @return TimesheetFixtures
|
||||
*/
|
||||
public function setCallback(callable $callback): TimesheetFixtures
|
||||
{
|
||||
$this->callback = $callback;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
@@ -246,7 +231,7 @@ class TimesheetFixtures extends Fixture
|
||||
|
||||
$tags = $this->getTagObjectList($i);
|
||||
|
||||
$entry = $this->createTimesheetEntry(
|
||||
$timesheet = $this->createTimesheetEntry(
|
||||
$user,
|
||||
$activity,
|
||||
$project,
|
||||
@@ -255,7 +240,10 @@ class TimesheetFixtures extends Fixture
|
||||
$tags
|
||||
);
|
||||
|
||||
$manager->persist($entry);
|
||||
if (null !== $this->callback) {
|
||||
call_user_func($this->callback, $timesheet);
|
||||
}
|
||||
$manager->persist($timesheet);
|
||||
}
|
||||
|
||||
for ($i = 0; $i < $this->running; $i++) {
|
||||
@@ -268,7 +256,7 @@ class TimesheetFixtures extends Fixture
|
||||
|
||||
$tags = $this->getTagObjectList($i);
|
||||
|
||||
$entry = $this->createTimesheetEntry(
|
||||
$timesheet = $this->createTimesheetEntry(
|
||||
$user,
|
||||
$activity,
|
||||
$project,
|
||||
@@ -277,7 +265,11 @@ class TimesheetFixtures extends Fixture
|
||||
$tags,
|
||||
false
|
||||
);
|
||||
$manager->persist($entry);
|
||||
|
||||
if (null !== $this->callback) {
|
||||
call_user_func($this->callback, $timesheet);
|
||||
}
|
||||
$manager->persist($timesheet);
|
||||
}
|
||||
|
||||
$manager->flush();
|
||||
|
||||
Reference in New Issue
Block a user