Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "friendsofsymfony/user-bundle" to development dependencies #166

Merged
merged 1 commit into from
Jul 6, 2020
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
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
20 changes: 10 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
cs:
vendor/bin/php-cs-fixer fix --verbose
.PHONY: cs

cs_dry_run:
vendor/bin/php-cs-fixer fix --verbose --dry-run

test:
vendor/bin/simple-phpunit -c phpunit.xml.dist --exclude-group vichuploaderbundle

test_with_vichuploaderbundle:
vendor/bin/simple-phpunit -c phpunit.xml.dist
.PHONY: cs_dry_run

all:
@echo "Please choose a task."
Expand Down Expand Up @@ -61,13 +57,17 @@ build:
mkdir $@

test:
ifeq ($(shell php --modules|grep --quiet pcov;echo $$?), 0)
vendor/bin/simple-phpunit -c phpunit.xml.dist --coverage-clover build/logs/clover.xml --exclude-group vichuploaderbundle
else
vendor/bin/simple-phpunit -c phpunit.xml.dist --exclude-group vichuploaderbundle
endif
.PHONY: test

test_with_vichuploaderbundle:
ifeq ($(shell php --modules|grep --quiet pcov;echo $$?), 0)
vendor/bin/simple-phpunit -c phpunit.xml.dist --coverage-clover build/logs/clover.xml
else
vendor/bin/simple-phpunit -c phpunit.xml.dist
endif
.PHONY: test

docs:
cd docs && sphinx-build -W -b html -d _build/doctrees . _build/html
.PHONY: docs
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;
}
46 changes: 37 additions & 9 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,11 +98,20 @@ 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',
],
],
'form' => null,
'validation' => [
'enabled' => true,
],
]);

// SecurityBundle config
Expand Down Expand Up @@ -131,34 +142,51 @@ 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,
'translation_domain' => 'HackzillaTicketBundle',
]);

if ($this->useVichUploaderBundle) {
// FrameworkBundle config
// "framework.form" is required since "vich_uploader.namer_directory_property"
// service uses "form.property_accessor" service.
$c->loadFromExtension('framework', [
'form' => null,
]);

// VichUploaderBundle config
$c->loadFromExtension('vich_uploader', [
'db_driver' => 'orm',
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