Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions Form/Type/PriorityType.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,22 @@
use Hackzilla\Bundle\TicketBundle\Model\TicketMessageInterface;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\OptionsResolver\OptionsResolver;

class PriorityType extends AbstractType
{
public function configureOptions(OptionsResolver $resolver)
{
$choices = TicketMessageInterface::PRIORITIES;
unset($choices[0]);
unset($choices[TicketMessageInterface::PRIORITY_INVALID]);

$resolver->setDefaults(
[
'choices_as_values' => true,
'choices' => array_flip($choices),
]
);
// Workaround for symfony/options-resolver >= 2.7, < 3.1.
if ($resolver->hasDefault('choices_as_values') && version_compare(Kernel::VERSION, '3.1', '<')) {
$resolver->setDefaults(['choices' => array_flip($choices), 'choices_as_values' => true]);
} else {
$resolver->setDefaults(['choices' => array_flip($choices)]);
}
}

public function getParent()
Expand Down
15 changes: 8 additions & 7 deletions Form/Type/StatusType.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,22 @@
use Hackzilla\Bundle\TicketBundle\Model\TicketMessageInterface;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\OptionsResolver\OptionsResolver;

class StatusType extends AbstractType
{
public function configureOptions(OptionsResolver $resolver)
{
$choices = TicketMessageInterface::STATUSES;
unset($choices[0]);
unset($choices[TicketMessageInterface::STATUS_INVALID]);

$resolver->setDefaults(
[
'choices_as_values' => true,
'choices' => array_flip($choices),
]
);
// Workaround for symfony/options-resolver >= 2.7, < 3.1.
if ($resolver->hasDefault('choices_as_values') && version_compare(Kernel::VERSION, '3.1', '<')) {
$resolver->setDefaults(['choices' => array_flip($choices), 'choices_as_values' => true]);
} else {
$resolver->setDefaults(['choices' => array_flip($choices)]);
}
}

public function getParent()
Expand Down
5 changes: 1 addition & 4 deletions Tests/EventListener/UserLoadTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@ public function setUp()

public function getUserManagerMock()
{
return $this
->getMockBuilder(UserManager::class)
->disableOriginalConstructor()
->getMock();
return $this->createMock(UserManager::class);
}

public function tearDown()
Expand Down
2 changes: 1 addition & 1 deletion Tests/Form/Type/TicketMessageTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class TicketMessageTypeTest extends TypeTestCase

protected function setUp()
{
$this->user = $this->getMockBuilder(UserManagerInterface::class)->getMock();
$this->user = $this->createMock(UserManagerInterface::class);

parent::setUp();
}
Expand Down
4 changes: 2 additions & 2 deletions Tests/Form/Type/TicketTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class TicketTypeTest extends TypeTestCase

protected function setUp()
{
$this->user = $this->getMockBuilder(UserManagerInterface::class)->getMock();
$this->user = $this->createMock(UserManagerInterface::class);

parent::setUp();
}
Expand All @@ -41,7 +41,7 @@ public function testSubmitValidData()
{
$formData = [];

$data = new \Hackzilla\Bundle\TicketBundle\Entity\Ticket();
$data = new Ticket();

$form = $this->factory->create(TicketType::class);

Expand Down
20 changes: 17 additions & 3 deletions Tests/Functional/TestKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,19 @@ protected function configureContainer(ContainerBuilder $c, LoaderInterface $load
]);

// SecurityBundle config
$mainFirewallConfig = ['anonymous' => null];
// "logout_on_user_change" configuration was marked as mandatory since version 3.4 and deprecated as of 4.1.
if (version_compare(self::VERSION, '3.4', '>=') && version_compare(self::VERSION, '4.1', '<')) {
$mainFirewallConfig['logout_on_user_change'] = true;
}
$c->loadFromExtension('security', [
'providers' => [
'in_memory' => [
'memory' => null,
],
],
'firewalls' => [
'main' => [
'anonymous' => null,
],
'main' => $mainFirewallConfig,
],
]);

Expand All @@ -105,6 +108,17 @@ protected function configureContainer(ContainerBuilder $c, LoaderInterface $load
],
]);

// TwigBundle config
$twigConfig = [
'strict_variables' => '%kernel.debug%',
'autoescape' => 'name',
];
// "default_path" configuration is available since version 3.4.
if (version_compare(self::VERSION, '3.4', '>=')) {
$twigConfig['default_path'] = __DIR__.'/Resources/views';
}
$c->loadFromExtension('twig', $twigConfig);

// HackzillaBundle config
$c->loadFromExtension('hackzilla_ticket', [
'user_class' => User::class,
Expand Down
7 changes: 1 addition & 6 deletions Tests/Manager/UserManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,7 @@ public function setUp()

private function getMockUserRepository()
{
$userRepository = $this
->getMockBuilder(EntityRepository::class)
->disableOriginalConstructor()
->getMock();

return $userRepository;
return $this->createMock(EntityRepository::class);
}

public function tearDown()
Expand Down
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
bootstrap="Tests/bootstrap.php"
>
<php>
<env name="SYMFONY_DEPRECATIONS_HELPER" value="weak" />
<env name="SYMFONY_DEPRECATIONS_HELPER" value="max[direct]=1" />
</php>
<testsuites>
<testsuite name="HackzillaTicketBundle test suite">
Expand Down