Skip to content

Commit 09f243b

Browse files
committed
Add "friendsofsymfony/user-bundle" to development dependencies
1 parent f2a52e1 commit 09f243b

File tree

9 files changed

+130
-77
lines changed

9 files changed

+130
-77
lines changed

.travis.yml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,15 @@ matrix:
2222
- php: 5.6
2323
env: SYMFONY_VERSION="~2.8.0" SYMFONY_PHPUNIT_VERSION="5.7.27"
2424
- php: 5.6
25-
env: SYMFONY_VERSION="~3.0.0" SYMFONY_PHPUNIT_VERSION="5.7.27"
26-
- php: 5.6
27-
env: SYMFONY_VERSION="~3.1.0" SYMFONY_PHPUNIT_VERSION="5.7.27"
28-
- php: 5.6
29-
env: SYMFONY_VERSION="~3.2.0" SYMFONY_PHPUNIT_VERSION="5.7.27"
25+
env: SYMFONY_VERSION="~3.4.0" SYMFONY_PHPUNIT_VERSION="5.7.27"
3026
- php: 5.6
3127
env: INSTALL_VICH_UPLOADER_BUNDLE=true SYMFONY_PHPUNIT_VERSION="5.7.27"
3228
- php: 7.0
3329
env: SYMFONY_PHPUNIT_VERSION="5.7.27"
3430
- php: 7.4
3531
env: COMPOSER_FLAGS="--prefer-lowest" SYMFONY_PHPUNIT_VERSION="5.7.27"
32+
- php: 7.4
33+
env: INSTALL_VICH_UPLOADER_BUNDLE=true
3634
allow_failures:
3735
- php: nightly
3836
- env: COMPOSER_FLAGS="--prefer-lowest" SYMFONY_PHPUNIT_VERSION="5.7.27"
@@ -48,8 +46,8 @@ before_script:
4846
- if [ "$GITHUB_OAUTH_TOKEN" != "" ]; then echo -e $GITHUB_OAUTH_TOKEN && composer config -g github-oauth.github.com $GITHUB_OAUTH_TOKEN; fi;
4947
- if [ 70100 -gt $(php -r 'echo PHP_VERSION_ID;') ]; then composer remove --dev "phpstan/phpstan" --no-update; fi;
5048
- if [ "$SYMFONY_VERSION" != "" ]; then composer require "symfony/symfony:${SYMFONY_VERSION}" --no-update; fi;
51-
- if [ -n $INSTALL_VICH_UPLOADER_BUNDLE ]; then composer require "vich/uploader-bundle" --no-update; fi;
49+
- if [ ! -z $INSTALL_VICH_UPLOADER_BUNDLE ]; then composer require "vich/uploader-bundle" --no-update; fi;
5250
- COMPOSER_MEMORY_LIMIT=-1 composer update --prefer-dist --no-interaction $COMPOSER_FLAGS
5351

5452
script:
55-
- if [[ -n $INSTALL_VICH_UPLOADER_BUNDLE ]]; then make test_with_vichuploaderbundle; else make test; fi;
53+
- if [ ! -z $INSTALL_VICH_UPLOADER_BUNDLE ]; then make test_with_vichuploaderbundle; else make test; fi;

Command/AutoClosingCommand.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,11 @@ protected function configure()
4444
*/
4545
protected function execute(InputInterface $input, OutputInterface $output)
4646
{
47-
$ticket_manager = $this->getContainer()->get('hackzilla_ticket.ticket_manager');
47+
if (!$this->getContainer()->has('fos_user.user_manager')) {
48+
throw new \RuntimeException(sprintf('Command "%s" requires the service "fos_user.user_manager". Is "friendsofsymfony/user-bundle" installed and enabled?', $this->getName()));
49+
}
50+
51+
$ticketManager = $this->getContainer()->get('hackzilla_ticket.ticket_manager');
4852
$userManager = $this->getContainer()->get('fos_user.user_manager');
4953
$ticketRepository = $this->getContainer()->get('doctrine')->getRepository('HackzillaTicketBundle:Ticket');
5054

@@ -59,7 +63,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
5963
$resolved_tickets = $ticketRepository->getResolvedTicketOlderThan($input->getOption('age'));
6064

6165
foreach ($resolved_tickets as $ticket) {
62-
$message = $ticket_manager->createMessage()
66+
$message = $ticketManager->createMessage()
6367
->setMessage(
6468
$translator->trans('MESSAGE_STATUS_CHANGED', ['%status%' => $translator->trans('STATUS_CLOSED', [], $translationDomain)], $translationDomain)
6569
)
@@ -69,7 +73,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
6973
->setTicket($ticket);
7074

7175
$ticket->setStatus(TicketMessage::STATUS_CLOSED);
72-
$ticket_manager->updateTicket($ticket, $message);
76+
$ticketManager->updateTicket($ticket, $message);
7377

7478
$output->writeln('The ticket "'.$ticket->getSubject().'" has been closed.');
7579
}

Command/TicketManagerCommand.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ protected function configure()
4949
*/
5050
protected function execute(InputInterface $input, OutputInterface $output)
5151
{
52+
if (!$this->getContainer()->has('fos_user.user_manager')) {
53+
throw new \RuntimeException(sprintf('Command "%s" requires the service "fos_user.user_manager". Is "friendsofsymfony/user-bundle" installed and enabled?', $this->getName()));
54+
}
55+
5256
$userManager = $this->getContainer()->get('fos_user.user_manager');
5357

5458
$ticketManager = $this->getContainer()->get('hackzilla_ticket.ticket_manager');

Makefile

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
cs:
22
vendor/bin/php-cs-fixer fix --verbose
3+
.PHONY: cs
34

45
cs_dry_run:
56
vendor/bin/php-cs-fixer fix --verbose --dry-run
6-
7-
test:
8-
vendor/bin/simple-phpunit -c phpunit.xml.dist --exclude-group vichuploaderbundle
9-
10-
test_with_vichuploaderbundle:
11-
vendor/bin/simple-phpunit -c phpunit.xml.dist
7+
.PHONY: cs_dry_run
128

139
all:
1410
@echo "Please choose a task."
@@ -61,13 +57,17 @@ build:
6157
mkdir $@
6258

6359
test:
60+
ifeq ($(shell php --modules|grep --quiet pcov;echo $$?), 0)
61+
vendor/bin/simple-phpunit -c phpunit.xml.dist --coverage-clover build/logs/clover.xml --exclude-group vichuploaderbundle
62+
else
63+
vendor/bin/simple-phpunit -c phpunit.xml.dist --exclude-group vichuploaderbundle
64+
endif
65+
.PHONY: test
66+
67+
test_with_vichuploaderbundle:
6468
ifeq ($(shell php --modules|grep --quiet pcov;echo $$?), 0)
6569
vendor/bin/simple-phpunit -c phpunit.xml.dist --coverage-clover build/logs/clover.xml
6670
else
6771
vendor/bin/simple-phpunit -c phpunit.xml.dist
6872
endif
6973
.PHONY: test
70-
71-
docs:
72-
cd docs && sphinx-build -W -b html -d _build/doctrees . _build/html
73-
.PHONY: docs

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Available translations for:
1818
## Requirements
1919

2020
* PHP >= 5.6
21-
* [Symfony][1] ^2.8|^3.0|^4.0
21+
* [Symfony][1] ^2.8|^3.4|^4.0
2222
* [Knp Paginator bundle][2]
2323
* [Bootstrap v3][3] (optional) see: [http://symfony.com/blog/new-in-symfony-2-6-bootstrap-form-theme][4]
2424

@@ -31,8 +31,8 @@ Available translations for:
3131

3232
| Ticket Bundle | Symfony | PHP |
3333
| --------------| ---------------- | ----- |
34-
| [3.x][6] | ^2.8\|^3.0\|^4.0 | >=5.6 |
35-
| [2.x][7] | ^2.7\|^3.0 | >=5.3 |
34+
| [3.x][6] | ^2.8\|^3.4\|^4.0 | >=5.6 |
35+
| [2.x][7] | ^2.7\|^3.4 | >=5.3 |
3636
| [1.x][8] | ^2.3 | >=5.3 |
3737
| [0.x][9] | ^2.3 | >=5.3 |
3838

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
namespace Hackzilla\Bundle\TicketBundle\Tests\Functional\Command;
4+
5+
use Hackzilla\Bundle\TicketBundle\Command\AutoClosingCommand;
6+
use Hackzilla\Bundle\TicketBundle\Command\TicketManagerCommand;
7+
use Hackzilla\Bundle\TicketBundle\Tests\Functional\WebTestCase;
8+
use Symfony\Bundle\FrameworkBundle\Console\Application;
9+
10+
/**
11+
* @author Javier Spagnoletti <[email protected]>
12+
*/
13+
final class ApplicationTest extends WebTestCase
14+
{
15+
/**
16+
* @dataProvider getCommands
17+
*
18+
* @param string $expectedClass
19+
* @param string $commandName
20+
*/
21+
public function testCommandRegistration($expectedClass, $commandName)
22+
{
23+
$application = new Application(static::$kernel);
24+
25+
$this->assertInstanceOf($expectedClass, $application->find($commandName));
26+
}
27+
28+
public function getCommands()
29+
{
30+
return [
31+
[AutoClosingCommand::class, 'ticket:autoclosing'],
32+
[TicketManagerCommand::class, 'ticket:create'],
33+
];
34+
}
35+
}

Tests/Functional/Entity/User.php

Lines changed: 12 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,38 +2,21 @@
22

33
namespace Hackzilla\Bundle\TicketBundle\Tests\Functional\Entity;
44

5-
use Hackzilla\Bundle\TicketBundle\Model\UserInterface;
5+
use Doctrine\ORM\Mapping as ORM;
6+
use FOS\UserBundle\Model\User as BaseUser;
67

78
/**
9+
* @ORM\Entity
10+
* @ORM\Table(name="fos_user")
11+
*
812
* @author Javier Spagnoletti <[email protected]>
913
*/
10-
final class User implements UserInterface
14+
class User extends BaseUser
1115
{
12-
public function getId()
13-
{
14-
}
15-
16-
public function getUsername()
17-
{
18-
}
19-
20-
public function getEmail()
21-
{
22-
}
23-
24-
public function getRoles()
25-
{
26-
}
27-
28-
public function getPassword()
29-
{
30-
}
31-
32-
public function getSalt()
33-
{
34-
}
35-
36-
public function eraseCredentials()
37-
{
38-
}
16+
/**
17+
* @ORM\Id
18+
* @ORM\Column(type="integer")
19+
* @ORM\GeneratedValue(strategy="AUTO")
20+
*/
21+
protected $id;
3922
}

Tests/Functional/TestKernel.php

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Hackzilla\Bundle\TicketBundle\Tests\Functional;
44

55
use Doctrine\Bundle\DoctrineBundle\DoctrineBundle;
6+
use FOS\UserBundle\FOSUserBundle;
67
use Hackzilla\Bundle\TicketBundle\HackzillaTicketBundle;
78
use Hackzilla\Bundle\TicketBundle\Tests\Functional\Entity\User;
89
use Knp\Bundle\PaginatorBundle\KnpPaginatorBundle;
@@ -41,6 +42,7 @@ public function registerBundles()
4142
new FrameworkBundle(),
4243
new SecurityBundle(),
4344
new DoctrineBundle(),
45+
new FOSUserBundle(),
4446
new KnpPaginatorBundle(),
4547
new TwigBundle(),
4648
new HackzillaTicketBundle(),
@@ -96,11 +98,20 @@ protected function configureContainer(ContainerBuilder $c, LoaderInterface $load
9698
$c->loadFromExtension('framework', [
9799
'secret' => 'MySecretKey',
98100
'default_locale' => 'en',
101+
'session' => [
102+
'handler_id' => 'session.handler.native_file',
103+
'storage_id' => 'session.storage.mock_file',
104+
'name' => 'MOCKSESSID',
105+
],
99106
'translator' => [
100107
'fallbacks' => [
101108
'en',
102109
],
103110
],
111+
'form' => null,
112+
'validation' => [
113+
'enabled' => true,
114+
],
104115
]);
105116

106117
// SecurityBundle config
@@ -131,34 +142,51 @@ protected function configureContainer(ContainerBuilder $c, LoaderInterface $load
131142
],
132143
'orm' => [
133144
'default_entity_manager' => 'default',
145+
'auto_mapping' => true,
146+
'mappings' => [
147+
'HackzillaTicketBundle' => [
148+
'dir' => __DIR__.'/Entity',
149+
'prefix' => 'Hackzilla\Bundle\TicketBundle\Tests\Functional\Entity',
150+
'alias' => 'HackzillaTicketBundle',
151+
'type' => 'annotation',
152+
],
153+
],
134154
],
135155
]);
136156

137157
// TwigBundle config
138158
$twigConfig = [
139-
'strict_variables' => '%kernel.debug%',
140-
'autoescape' => 'name',
159+
'strict_variables' => '%kernel.debug%',
160+
'exception_controller' => null,
161+
'autoescape' => 'name',
141162
];
142163
// "default_path" configuration is available since version 3.4.
143164
if (version_compare(self::VERSION, '3.4', '>=')) {
144165
$twigConfig['default_path'] = __DIR__.'/Resources/views';
145166
}
146167
$c->loadFromExtension('twig', $twigConfig);
147168

169+
// FOSUserBundle config
170+
$c->loadFromExtension('fos_user', [
171+
'user_class' => User::class,
172+
'db_driver' => 'orm',
173+
'firewall_name' => 'api',
174+
'from_email' => [
175+
'address' => '[email protected]',
176+
'sender_name' => 'HackzillaTicketBundle',
177+
],
178+
'service' => [
179+
'mailer' => 'fos_user.mailer.noop',
180+
],
181+
]);
182+
148183
// HackzillaBundle config
149184
$c->loadFromExtension('hackzilla_ticket', [
150185
'user_class' => User::class,
151186
'translation_domain' => 'HackzillaTicketBundle',
152187
]);
153188

154189
if ($this->useVichUploaderBundle) {
155-
// FrameworkBundle config
156-
// "framework.form" is required since "vich_uploader.namer_directory_property"
157-
// service uses "form.property_accessor" service.
158-
$c->loadFromExtension('framework', [
159-
'form' => null,
160-
]);
161-
162190
// VichUploaderBundle config
163191
$c->loadFromExtension('vich_uploader', [
164192
'db_driver' => 'orm',

composer.json

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,30 +28,31 @@
2828
"php": "^5.6 || ^7.0",
2929
"doctrine/doctrine-bundle": "^1.4 || ^2.0",
3030
"doctrine/orm": "^2.4.8",
31-
"knplabs/knp-paginator-bundle": "^2.6 || ^3.0 || ^4.0 || ^5.0",
32-
"symfony/config": "^2.8 || ^3.0 || ^4.0",
33-
"symfony/console": "^2.8 || ^3.0 || ^4.0",
34-
"symfony/dependency-injection": "^2.8 || ^3.0 || ^4.0",
35-
"symfony/event-dispatcher": "^2.8 || ^3.0 || ^4.0",
36-
"symfony/form": "^2.8 || ^3.0 || ^4.0",
37-
"symfony/framework-bundle": "^2.8.1 || ^3.0 || ^4.0",
38-
"symfony/http-foundation": "^2.8 || ^3.0 || ^4.0",
39-
"symfony/http-kernel": "^2.8 || ^3.0 || ^4.0",
40-
"symfony/options-resolver": "^2.8 || ^3.0 || ^4.0",
41-
"symfony/security-bundle": "^2.8 || ^3.0 || ^4.0",
42-
"symfony/translation": "^2.8 || ^3.0 || ^4.0",
43-
"symfony/twig-bundle": "^2.8 || ^3.0 || ^4.0",
44-
"symfony/validator": "^2.8 || ^3.0 || ^4.0",
45-
"symfony/yaml": "^2.8 || ^3.0 || ^4.0",
31+
"knplabs/knp-paginator-bundle": "^2.6 || ^3.4 || ^4.0 || ^5.0",
32+
"symfony/config": "^2.8 || ^3.4 || ^4.0",
33+
"symfony/console": "^2.8 || ^3.4 || ^4.0",
34+
"symfony/dependency-injection": "^2.8 || ^3.4 || ^4.0",
35+
"symfony/event-dispatcher": "^2.8 || ^3.4 || ^4.0",
36+
"symfony/form": "^2.8 || ^3.4 || ^4.0",
37+
"symfony/framework-bundle": "^2.8.1 || ^3.4 || ^4.0",
38+
"symfony/http-foundation": "^2.8 || ^3.4 || ^4.0",
39+
"symfony/http-kernel": "^2.8 || ^3.4 || ^4.0",
40+
"symfony/options-resolver": "^2.8 || ^3.4 || ^4.0",
41+
"symfony/security-bundle": "^2.8 || ^3.4 || ^4.0",
42+
"symfony/translation": "^2.8 || ^3.4 || ^4.0",
43+
"symfony/twig-bundle": "^2.8 || ^3.4 || ^4.0",
44+
"symfony/validator": "^2.8 || ^3.4 || ^4.0",
45+
"symfony/yaml": "^2.8 || ^3.4 || ^4.0",
4646
"twig/twig": "^1.34 || ^2.0"
4747
},
4848
"require-dev": {
4949
"ext-pdo_sqlite": "*",
5050
"friendsofphp/php-cs-fixer": "^1.4 || ^2.0",
51+
"friendsofsymfony/user-bundle": "^1.3 || ^2.1",
5152
"phpstan/phpstan": "^0.12.32",
5253
"phpunit/phpunit": ">=5.4.3,<8.0",
5354
"symfony/phpunit-bridge": "^3.2 || ^4.0",
54-
"symfony/security": "^2.8 || ^3.0 || ^4.0"
55+
"symfony/security": "^2.8 || ^3.4 || ^4.0"
5556
},
5657
"suggest": {
5758
"friendsofsymfony/user-bundle": "In order to ease user management",

0 commit comments

Comments
 (0)