Skip to content

Commit

Permalink
Add "friendsofsymfony/user-bundle" to development dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
phansys committed Jul 5, 2020
1 parent f2a52e1 commit fd798e9
Show file tree
Hide file tree
Showing 8 changed files with 116 additions and 60 deletions.
12 changes: 5 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,15 @@ matrix:
- php: 5.6
env: SYMFONY_VERSION="~2.8.0" SYMFONY_PHPUNIT_VERSION="5.7.27"
- php: 5.6
env: SYMFONY_VERSION="~3.0.0" SYMFONY_PHPUNIT_VERSION="5.7.27"
- php: 5.6
env: SYMFONY_VERSION="~3.1.0" SYMFONY_PHPUNIT_VERSION="5.7.27"
- php: 5.6
env: SYMFONY_VERSION="~3.2.0" SYMFONY_PHPUNIT_VERSION="5.7.27"
env: SYMFONY_VERSION="~3.4.0" SYMFONY_PHPUNIT_VERSION="5.7.27"
- php: 5.6
env: INSTALL_VICH_UPLOADER_BUNDLE=true SYMFONY_PHPUNIT_VERSION="5.7.27"
- php: 7.0
env: SYMFONY_PHPUNIT_VERSION="5.7.27"
- php: 7.4
env: COMPOSER_FLAGS="--prefer-lowest" SYMFONY_PHPUNIT_VERSION="5.7.27"
- php: 7.4
env: INSTALL_VICH_UPLOADER_BUNDLE=true
allow_failures:
- php: nightly
- env: COMPOSER_FLAGS="--prefer-lowest" SYMFONY_PHPUNIT_VERSION="5.7.27"
Expand All @@ -48,8 +46,8 @@ before_script:
- if [ "$GITHUB_OAUTH_TOKEN" != "" ]; then echo -e $GITHUB_OAUTH_TOKEN && composer config -g github-oauth.github.com $GITHUB_OAUTH_TOKEN; fi;
- if [ 70100 -gt $(php -r 'echo PHP_VERSION_ID;') ]; then composer remove --dev "phpstan/phpstan" --no-update; fi;
- if [ "$SYMFONY_VERSION" != "" ]; then composer require "symfony/symfony:${SYMFONY_VERSION}" --no-update; fi;
- if [ -n $INSTALL_VICH_UPLOADER_BUNDLE ]; then composer require "vich/uploader-bundle" --no-update; fi;
- if [ ! -z $INSTALL_VICH_UPLOADER_BUNDLE ]; then composer require "vich/uploader-bundle" --no-update; fi;
- COMPOSER_MEMORY_LIMIT=-1 composer update --prefer-dist --no-interaction $COMPOSER_FLAGS

script:
- if [[ -n $INSTALL_VICH_UPLOADER_BUNDLE ]]; then make test_with_vichuploaderbundle; else make test; fi;
- if [ ! -z $INSTALL_VICH_UPLOADER_BUNDLE ]; then make test_with_vichuploaderbundle; else make test; fi;
10 changes: 7 additions & 3 deletions Command/AutoClosingCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ protected function configure()
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$ticket_manager = $this->getContainer()->get('hackzilla_ticket.ticket_manager');
if (!$this->getContainer()->has('fos_user.user_manager')) {
throw new \RuntimeException(sprintf('Command "%s" requires the service "fos_user.user_manager". Is "friendsofsymfony/user-bundle" installed and enabled?', $this->getName()));
}

$ticketManager = $this->getContainer()->get('hackzilla_ticket.ticket_manager');
$userManager = $this->getContainer()->get('fos_user.user_manager');
$ticketRepository = $this->getContainer()->get('doctrine')->getRepository('HackzillaTicketBundle:Ticket');

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

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

$ticket->setStatus(TicketMessage::STATUS_CLOSED);
$ticket_manager->updateTicket($ticket, $message);
$ticketManager->updateTicket($ticket, $message);

$output->writeln('The ticket "'.$ticket->getSubject().'" has been closed.');
}
Expand Down
4 changes: 4 additions & 0 deletions Command/TicketManagerCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ protected function configure()
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
if (!$this->getContainer()->has('fos_user.user_manager')) {
throw new \RuntimeException(sprintf('Command "%s" requires the service "fos_user.user_manager". Is "friendsofsymfony/user-bundle" installed and enabled?', $this->getName()));
}

$userManager = $this->getContainer()->get('fos_user.user_manager');

$ticketManager = $this->getContainer()->get('hackzilla_ticket.ticket_manager');
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Available translations for:
## Requirements

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

Expand All @@ -31,8 +31,8 @@ Available translations for:

| Ticket Bundle | Symfony | PHP |
| --------------| ---------------- | ----- |
| [3.x][6] | ^2.8\|^3.0\|^4.0 | >=5.6 |
| [2.x][7] | ^2.7\|^3.0 | >=5.3 |
| [3.x][6] | ^2.8\|^3.4\|^4.0 | >=5.6 |
| [2.x][7] | ^2.7\|^3.4 | >=5.3 |
| [1.x][8] | ^2.3 | >=5.3 |
| [0.x][9] | ^2.3 | >=5.3 |

Expand Down
35 changes: 35 additions & 0 deletions Tests/Functional/Command/ApplicationTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

namespace Hackzilla\Bundle\TicketBundle\Tests\Functional\Command;

use Hackzilla\Bundle\TicketBundle\Command\AutoClosingCommand;
use Hackzilla\Bundle\TicketBundle\Command\TicketManagerCommand;
use Hackzilla\Bundle\TicketBundle\Tests\Functional\WebTestCase;
use Symfony\Bundle\FrameworkBundle\Console\Application;

/**
* @author Javier Spagnoletti <phansys@gmail.com>
*/
final class ApplicationTest extends WebTestCase
{
/**
* @dataProvider getCommands
*
* @param string $expectedClass
* @param string $commandName
*/
public function testCommandRegistration($expectedClass, $commandName)
{
$application = new Application(static::$kernel);

$this->assertInstanceOf($expectedClass, $application->find($commandName));
}

public function getCommands()
{
return [
[AutoClosingCommand::class, 'ticket:autoclosing'],
[TicketManagerCommand::class, 'ticket:create'],
];
}
}
41 changes: 12 additions & 29 deletions Tests/Functional/Entity/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,21 @@

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

use Hackzilla\Bundle\TicketBundle\Model\UserInterface;
use Doctrine\ORM\Mapping as ORM;
use FOS\UserBundle\Model\User as BaseUser;

/**
* @ORM\Entity
* @ORM\Table(name="fos_user")
*
* @author Javier Spagnoletti <phansys@gmail.com>
*/
final class User implements UserInterface
class User extends BaseUser
{
public function getId()
{
}

public function getUsername()
{
}

public function getEmail()
{
}

public function getRoles()
{
}

public function getPassword()
{
}

public function getSalt()
{
}

public function eraseCredentials()
{
}
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
}
35 changes: 33 additions & 2 deletions Tests/Functional/TestKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Hackzilla\Bundle\TicketBundle\Tests\Functional;

use Doctrine\Bundle\DoctrineBundle\DoctrineBundle;
use FOS\UserBundle\FOSUserBundle;
use Hackzilla\Bundle\TicketBundle\HackzillaTicketBundle;
use Hackzilla\Bundle\TicketBundle\Tests\Functional\Entity\User;
use Knp\Bundle\PaginatorBundle\KnpPaginatorBundle;
Expand Down Expand Up @@ -41,6 +42,7 @@ public function registerBundles()
new FrameworkBundle(),
new SecurityBundle(),
new DoctrineBundle(),
new FOSUserBundle(),
new KnpPaginatorBundle(),
new TwigBundle(),
new HackzillaTicketBundle(),
Expand Down Expand Up @@ -96,6 +98,11 @@ protected function configureContainer(ContainerBuilder $c, LoaderInterface $load
$c->loadFromExtension('framework', [
'secret' => 'MySecretKey',
'default_locale' => 'en',
'session' => [
'handler_id' => 'session.handler.native_file',
'storage_id' => 'session.storage.mock_file',
'name' => 'MOCKSESSID',
],
'translator' => [
'fallbacks' => [
'en',
Expand Down Expand Up @@ -131,20 +138,44 @@ protected function configureContainer(ContainerBuilder $c, LoaderInterface $load
],
'orm' => [
'default_entity_manager' => 'default',
'auto_mapping' => true,
'mappings' => [
'HackzillaTicketBundle' => [
'dir' => __DIR__.'/Entity',
'prefix' => 'Hackzilla\Bundle\TicketBundle\Tests\Functional\Entity',
'alias' => 'HackzillaTicketBundle',
'type' => 'annotation',
],
],
],
]);

// TwigBundle config
$twigConfig = [
'strict_variables' => '%kernel.debug%',
'autoescape' => 'name',
'strict_variables' => '%kernel.debug%',
'exception_controller' => null,
'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);

// FOSUserBundle config
$c->loadFromExtension('fos_user', [
'user_class' => User::class,
'db_driver' => 'orm',
'firewall_name' => 'api',
'from_email' => [
'address' => 'no-reply@example.com',
'sender_name' => 'HackzillaTicketBundle',
],
'service' => [
'mailer' => 'fos_user.mailer.noop',
],
]);

// HackzillaBundle config
$c->loadFromExtension('hackzilla_ticket', [
'user_class' => User::class,
Expand Down
33 changes: 17 additions & 16 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,30 +28,31 @@
"php": "^5.6 || ^7.0",
"doctrine/doctrine-bundle": "^1.4 || ^2.0",
"doctrine/orm": "^2.4.8",
"knplabs/knp-paginator-bundle": "^2.6 || ^3.0 || ^4.0 || ^5.0",
"symfony/config": "^2.8 || ^3.0 || ^4.0",
"symfony/console": "^2.8 || ^3.0 || ^4.0",
"symfony/dependency-injection": "^2.8 || ^3.0 || ^4.0",
"symfony/event-dispatcher": "^2.8 || ^3.0 || ^4.0",
"symfony/form": "^2.8 || ^3.0 || ^4.0",
"symfony/framework-bundle": "^2.8.1 || ^3.0 || ^4.0",
"symfony/http-foundation": "^2.8 || ^3.0 || ^4.0",
"symfony/http-kernel": "^2.8 || ^3.0 || ^4.0",
"symfony/options-resolver": "^2.8 || ^3.0 || ^4.0",
"symfony/security-bundle": "^2.8 || ^3.0 || ^4.0",
"symfony/translation": "^2.8 || ^3.0 || ^4.0",
"symfony/twig-bundle": "^2.8 || ^3.0 || ^4.0",
"symfony/validator": "^2.8 || ^3.0 || ^4.0",
"symfony/yaml": "^2.8 || ^3.0 || ^4.0",
"knplabs/knp-paginator-bundle": "^2.6 || ^3.4 || ^4.0 || ^5.0",
"symfony/config": "^2.8 || ^3.4 || ^4.0",
"symfony/console": "^2.8 || ^3.4 || ^4.0",
"symfony/dependency-injection": "^2.8 || ^3.4 || ^4.0",
"symfony/event-dispatcher": "^2.8 || ^3.4 || ^4.0",
"symfony/form": "^2.8 || ^3.4 || ^4.0",
"symfony/framework-bundle": "^2.8.1 || ^3.4 || ^4.0",
"symfony/http-foundation": "^2.8 || ^3.4 || ^4.0",
"symfony/http-kernel": "^2.8 || ^3.4 || ^4.0",
"symfony/options-resolver": "^2.8 || ^3.4 || ^4.0",
"symfony/security-bundle": "^2.8 || ^3.4 || ^4.0",
"symfony/translation": "^2.8 || ^3.4 || ^4.0",
"symfony/twig-bundle": "^2.8 || ^3.4 || ^4.0",
"symfony/validator": "^2.8 || ^3.4 || ^4.0",
"symfony/yaml": "^2.8 || ^3.4 || ^4.0",
"twig/twig": "^1.34 || ^2.0"
},
"require-dev": {
"ext-pdo_sqlite": "*",
"friendsofphp/php-cs-fixer": "^1.4 || ^2.0",
"friendsofsymfony/user-bundle": "^1.3 || ^2.1",
"phpstan/phpstan": "^0.12.32",
"phpunit/phpunit": ">=5.4.3,<8.0",
"symfony/phpunit-bridge": "^3.2 || ^4.0",
"symfony/security": "^2.8 || ^3.0 || ^4.0"
"symfony/security": "^2.8 || ^3.4 || ^4.0"
},
"suggest": {
"friendsofsymfony/user-bundle": "In order to ease user management",
Expand Down

0 comments on commit fd798e9

Please sign in to comment.