Skip to content

Commit

Permalink
Add a functional test (FriendsOfSymfony#330)
Browse files Browse the repository at this point in the history
* Add a functional test

* CS
  • Loading branch information
GuilhemN authored Sep 15, 2018
1 parent 3196bb0 commit ad8b51c
Show file tree
Hide file tree
Showing 53 changed files with 489 additions and 101 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
composer.lock
phpunit.xml
vendor
.phpunit
vendor
.php_cs.cache
.php_cs
Tests/Functional/cache
Tests/Functional/logs
10 changes: 0 additions & 10 deletions .php_cs

This file was deleted.

15 changes: 15 additions & 0 deletions .php_cs.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

$finder = PhpCsFixer\Finder::create()
->in(__DIR__)
->exclude('Tests/Functional/cache')
;

return PhpCsFixer\Config::create()
->setRules(array(
'@Symfony' => true,
'ordered_imports' => true,
'phpdoc_order' => true,
))
->setFinder($finder)
;
5 changes: 2 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
language: php

sudo: false
dist: precise

cache:
directories:
Expand All @@ -15,10 +14,10 @@ branches:
matrix:
fast_finish: true
include:
- php: 5.3
- php: 5.5
env: COMPOSER_FLAGS="--prefer-lowest" SYMFONY_DEPRECATIONS_HELPER=weak
- php: 7.2
env: SYMFONY_LTS='^3'
env: SYMFONY_LTS='^3' SYMFONY_DEPRECATIONS_HELPER=weak
- php: 7.2

before_install:
Expand Down
8 changes: 4 additions & 4 deletions Command/MongoDBMigrateMetadataCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ private function createThreadActiveParticipantArrays(array &$thread)

foreach ($thread['participants'] as $participantRef) {
foreach ($thread['metadata'] as $metadata) {
if ($metadata['isDeleted'] && $participantRef['$id'] === $metadata['participant']['$id']) {
if ($metadata['isDeleted'] && $metadata['participant']['$id'] === $participantRef['$id']) {
continue 2;
}
}
Expand All @@ -361,7 +361,7 @@ private function createThreadActiveParticipantArrays(array &$thread)
throw new \UnexpectedValueException(sprintf('Sender reference not found for message "%s"', $messageRef['$id']));
}

if ($participantRef['$id'] == $message['sender']['$id']) {
if ($message['sender']['$id'] == $participantRef['$id']) {
$participantIsActiveSender = true;
} elseif (!$thread['isSpam']) {
$participantIsActiveRecipient = true;
Expand Down Expand Up @@ -396,9 +396,9 @@ private function createThreadActiveParticipantArrays(array &$thread)
* @param ManagerRegistry $registry
* @param string $class
*
* @return \MongoCollection
*
* @throws \RuntimeException if the class has no DocumentManager
*
* @return \MongoCollection
*/
private function getMongoCollectionForClass(ManagerRegistry $registry, $class)
{
Expand Down
6 changes: 3 additions & 3 deletions Composer/Composer.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

namespace FOS\MessageBundle\Composer;

use FOS\MessageBundle\ModelManager\MessageManagerInterface;
use FOS\MessageBundle\Model\ThreadInterface;
use FOS\MessageBundle\ModelManager\ThreadManagerInterface;
use FOS\MessageBundle\MessageBuilder\NewThreadMessageBuilder;
use FOS\MessageBundle\MessageBuilder\ReplyMessageBuilder;
use FOS\MessageBundle\Model\ThreadInterface;
use FOS\MessageBundle\ModelManager\MessageManagerInterface;
use FOS\MessageBundle\ModelManager\ThreadManagerInterface;

/**
* Factory for message builders.
Expand Down
2 changes: 1 addition & 1 deletion Controller/MessageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function sentAction()
{
$threads = $this->getProvider()->getSentThreads();

return $this->render('@FOSMessage/Message/sent.html.twig',, array(
return $this->render('@FOSMessage/Message/sent.html.twig', array(
'threads' => $threads,
));
}
Expand Down
6 changes: 3 additions & 3 deletions DataTransformer/RecipientsDataTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

namespace FOS\MessageBundle\DataTransformer;

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Symfony\Component\Form\DataTransformerInterface;
use Symfony\Component\Form\Exception\TransformationFailedException;
use Symfony\Component\Form\Exception\UnexpectedTypeException;
use Symfony\Component\Security\Core\User\UserInterface;
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\ArrayCollection;

/**
* Transforms collection of UserInterface into strings separated with coma.
Expand Down Expand Up @@ -35,7 +35,7 @@ public function __construct(DataTransformerInterface $userToUsernameTransformer)
*/
public function transform($recipients)
{
if ($recipients === null || $recipients->count() === 0) {
if (null === $recipients || 0 === $recipients->count()) {
return '';
}

Expand Down
8 changes: 4 additions & 4 deletions Deleter/Deleter.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

namespace FOS\MessageBundle\Deleter;

use FOS\MessageBundle\Event\FOSMessageEvents;
use FOS\MessageBundle\Event\ThreadEvent;
use FOS\MessageBundle\Model\ParticipantInterface;
use FOS\MessageBundle\Security\AuthorizerInterface;
use FOS\MessageBundle\Model\ThreadInterface;
use FOS\MessageBundle\Security\AuthorizerInterface;
use FOS\MessageBundle\Security\ParticipantProviderInterface;
use FOS\MessageBundle\Event\FOSMessageEvents;
use FOS\MessageBundle\Event\ThreadEvent;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;

/**
* Marks threads as deleted.
Expand Down
6 changes: 3 additions & 3 deletions DependencyInjection/FOSMessageExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
namespace FOS\MessageBundle\DependencyInjection;

use Symfony\Component\Config\Definition\Processor;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\Alias;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Config\FileLocator;

class FOSMessageExtension extends Extension
{
Expand Down
2 changes: 1 addition & 1 deletion Document/Thread.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace FOS\MessageBundle\Document;

use FOS\MessageBundle\Model\Thread as AbstractThread;
use FOS\MessageBundle\Model\ParticipantInterface;
use FOS\MessageBundle\Model\Thread as AbstractThread;

abstract class Thread extends AbstractThread
{
Expand Down
6 changes: 3 additions & 3 deletions DocumentManager/MessageManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
namespace FOS\MessageBundle\DocumentManager;

use Doctrine\ODM\MongoDB\DocumentManager;
use Doctrine\ODM\MongoDB\Query\Builder;
use FOS\MessageBundle\Document\Message;
use FOS\MessageBundle\Document\MessageMetadata;
use FOS\MessageBundle\Model\MessageInterface;
use FOS\MessageBundle\ModelManager\MessageManager as BaseMessageManager;
use FOS\MessageBundle\Model\ReadableInterface;
use FOS\MessageBundle\Model\ParticipantInterface;
use FOS\MessageBundle\Model\ReadableInterface;
use FOS\MessageBundle\Model\ThreadInterface;
use Doctrine\ODM\MongoDB\Query\Builder;
use FOS\MessageBundle\ModelManager\MessageManager as BaseMessageManager;

/**
* Default MongoDB MessageManager.
Expand Down
4 changes: 2 additions & 2 deletions DocumentManager/ThreadManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
use Doctrine\ODM\MongoDB\DocumentManager;
use FOS\MessageBundle\Document\Thread;
use FOS\MessageBundle\Document\ThreadMetadata;
use FOS\MessageBundle\Model\ThreadInterface;
use FOS\MessageBundle\Model\ParticipantInterface;
use FOS\MessageBundle\Model\ReadableInterface;
use FOS\MessageBundle\Model\ThreadInterface;
use FOS\MessageBundle\ModelManager\ThreadManager as BaseThreadManager;
use FOS\MessageBundle\Model\ParticipantInterface;

/**
* Default MongoDB ThreadManager.
Expand Down
2 changes: 1 addition & 1 deletion Entity/MessageMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace FOS\MessageBundle\Entity;

use FOS\MessageBundle\Model\MessageMetadata as BaseMessageMetadata;
use FOS\MessageBundle\Model\MessageInterface;
use FOS\MessageBundle\Model\MessageMetadata as BaseMessageMetadata;

abstract class MessageMetadata extends BaseMessageMetadata
{
Expand Down
2 changes: 1 addition & 1 deletion Entity/Thread.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use FOS\MessageBundle\Model\MessageInterface;
use FOS\MessageBundle\Model\Thread as BaseThread;
use FOS\MessageBundle\Model\ParticipantInterface;
use FOS\MessageBundle\Model\Thread as BaseThread;
use FOS\MessageBundle\Model\ThreadMetadata as ModelThreadMetadata;

abstract class Thread extends BaseThread
Expand Down
4 changes: 2 additions & 2 deletions EntityManager/MessageManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

namespace FOS\MessageBundle\EntityManager;

use FOS\MessageBundle\ModelManager\MessageManager as BaseMessageManager;
use Doctrine\ORM\EntityManager;
use FOS\MessageBundle\Model\MessageInterface;
use FOS\MessageBundle\Model\ReadableInterface;
use FOS\MessageBundle\Model\ParticipantInterface;
use FOS\MessageBundle\Model\ReadableInterface;
use FOS\MessageBundle\Model\ThreadInterface;
use FOS\MessageBundle\ModelManager\MessageManager as BaseMessageManager;

/**
* Default ORM MessageManager.
Expand Down
6 changes: 3 additions & 3 deletions EntityManager/ThreadManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

namespace FOS\MessageBundle\EntityManager;

use FOS\MessageBundle\ModelManager\ThreadManager as BaseThreadManager;
use Doctrine\ORM\EntityManager;
use FOS\MessageBundle\Model\ThreadInterface;
use FOS\MessageBundle\Model\ReadableInterface;
use FOS\MessageBundle\Model\ParticipantInterface;
use FOS\MessageBundle\Model\ReadableInterface;
use FOS\MessageBundle\Model\ThreadInterface;
use FOS\MessageBundle\ModelManager\ThreadManager as BaseThreadManager;

/**
* Default ORM ThreadManager.
Expand Down
2 changes: 1 addition & 1 deletion Event/ReadableEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace FOS\MessageBundle\Event;

use Symfony\Component\EventDispatcher\Event;
use FOS\MessageBundle\Model\ReadableInterface;
use Symfony\Component\EventDispatcher\Event;

class ReadableEvent extends Event
{
Expand Down
2 changes: 1 addition & 1 deletion Event/ThreadEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace FOS\MessageBundle\Event;

use Symfony\Component\EventDispatcher\Event;
use FOS\MessageBundle\Model\ThreadInterface;
use Symfony\Component\EventDispatcher\Event;

class ThreadEvent extends Event
{
Expand Down
2 changes: 1 addition & 1 deletion FormFactory/AbstractMessageFormFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace FOS\MessageBundle\FormFactory;

use FOS\MessageBundle\FormModel\AbstractMessage;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormFactoryInterface;
use FOS\MessageBundle\FormModel\AbstractMessage;

/**
* Instanciates message forms.
Expand Down
10 changes: 5 additions & 5 deletions FormHandler/AbstractMessageFormHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

namespace FOS\MessageBundle\FormHandler;

use FOS\MessageBundle\Model\MessageInterface;
use Symfony\Component\Form\Form;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
use FOS\MessageBundle\Composer\ComposerInterface;
use FOS\MessageBundle\FormModel\AbstractMessage;
use FOS\MessageBundle\Security\ParticipantProviderInterface;
use FOS\MessageBundle\Model\MessageInterface;
use FOS\MessageBundle\Model\ParticipantInterface;
use FOS\MessageBundle\Security\ParticipantProviderInterface;
use FOS\MessageBundle\Sender\SenderInterface;
use Symfony\Component\Form\Form;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;

/**
* Handles messages forms, from binding request to sending the message.
Expand Down
4 changes: 2 additions & 2 deletions FormHandler/NewThreadMessageFormHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ class NewThreadMessageFormHandler extends AbstractMessageFormHandler
*
* @param AbstractMessage $message
*
* @return MessageInterface the composed message ready to be sent
*
* @throws \InvalidArgumentException if the message is not a NewThreadMessage
*
* @return MessageInterface the composed message ready to be sent
*/
public function composeMessage(AbstractMessage $message)
{
Expand Down
4 changes: 2 additions & 2 deletions FormHandler/NewThreadMultipleMessageFormHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ class NewThreadMultipleMessageFormHandler extends AbstractMessageFormHandler
*
* @param AbstractMessage $message
*
* @return MessageInterface the composed message ready to be sent
*
* @throws \InvalidArgumentException if the message is not a NewThreadMessage
*
* @return MessageInterface the composed message ready to be sent
*/
public function composeMessage(AbstractMessage $message)
{
Expand Down
4 changes: 2 additions & 2 deletions FormHandler/ReplyMessageFormHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ class ReplyMessageFormHandler extends AbstractMessageFormHandler
*
* @param AbstractMessage $message
*
* @return MessageInterface the composed message ready to be sent
*
* @throws \InvalidArgumentException if the message is not a ReplyMessage
*
* @return MessageInterface the composed message ready to be sent
*/
public function composeMessage(AbstractMessage $message)
{
Expand Down
2 changes: 1 addition & 1 deletion FormType/NewThreadMultipleMessageFormType.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
namespace FOS\MessageBundle\FormType;

use FOS\MessageBundle\Util\LegacyFormHelper;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;

/**
* Message form type for starting a new conversation with multiple recipients.
Expand Down
2 changes: 1 addition & 1 deletion FormType/RecipientsType.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

namespace FOS\MessageBundle\FormType;

use FOS\MessageBundle\DataTransformer\RecipientsDataTransformer;
use FOS\MessageBundle\Util\LegacyFormHelper;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
use FOS\MessageBundle\DataTransformer\RecipientsDataTransformer;

/**
* Description of RecipientsType.
Expand Down
2 changes: 1 addition & 1 deletion MessageBuilder/NewThreadMessageBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace FOS\MessageBundle\MessageBuilder;

use FOS\MessageBundle\Model\ParticipantInterface;
use Doctrine\Common\Collections\Collection;
use FOS\MessageBundle\Model\ParticipantInterface;

/**
* Fluent interface message builder for new thread messages.
Expand Down
2 changes: 1 addition & 1 deletion ModelManager/ReadableManagerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace FOS\MessageBundle\ModelManager;

use FOS\MessageBundle\Model\ReadableInterface;
use FOS\MessageBundle\Model\ParticipantInterface;
use FOS\MessageBundle\Model\ReadableInterface;

/**
* Capable of updating the read state of objects directly in the storage,
Expand Down
Loading

0 comments on commit ad8b51c

Please sign in to comment.