Skip to content

Commit

Permalink
Merge pull request #11 from bukhr/feature/upgrade-symfony-6
Browse files Browse the repository at this point in the history
Feature - Upgrade Symfony 6
  • Loading branch information
gfuentesboost authored Jun 4, 2024
2 parents 273ef75 + 1628cf1 commit 95448aa
Show file tree
Hide file tree
Showing 13 changed files with 117 additions and 220 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ jobs:
matrix:
include:
- php: '8.1'
symfony_require: '4.4.*'
- php: '8.3'
symfony_require: '5.4.*'
- php: '8.3'
symfony_require: '6.4.*'

fail-fast: false
steps:
Expand Down
36 changes: 18 additions & 18 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,20 @@
}
],
"require": {
"php": ">=7.4",
"php": "^8.1",
"friendsofsymfony/rest-bundle": "^3.0",
"jms/serializer-bundle": "^3.0",
"symfony/framework-bundle": "^5.4",
"symfony/asset": "^5.4",
"symfony/dependency-injection": "^5.4",
"symfony/routing": "^5.4",
"symfony/security-bundle": "^5.4",
"symfony/yaml": "^5.4",
"symfony/form": "^5.4",
"symfony/validator": "^5.4",
"symfony/twig-bundle": "^5.4",
"symfony/twig-bridge": "^5.4",
"twig/twig": "^2.0|^3.0",
"jms/serializer-bundle": "^4.0|^5.0",
"symfony/framework-bundle": "^5.4|^6.4",
"symfony/asset": "^5.4|^6.4",
"symfony/dependency-injection": "^5.4|^6.4",
"symfony/routing": "^5.4|^6.4",
"symfony/security-bundle": "^5.4|^6.4",
"symfony/yaml": "^5.4|^6.4",
"symfony/form": "^5.4|^6.4",
"symfony/validator": "^5.4|^6.4",
"symfony/twig-bundle": "^5.4|^6.4",
"symfony/twig-bridge": "^5.4|^6.4",
"twig/twig": "^3.0",
"phpoption/phpoption": "^1.1",
"doctrine/annotations": "^1.0",
"handcraftedinthealps/rest-routing-bundle": "^1.0"
Expand All @@ -44,14 +44,14 @@
"symfony/assetic-bundle": "Integrates Assetic into Symfony."
},
"require-dev": {
"symfony/browser-kit": "^5.4",
"symfony/dom-crawler": "^5.4",
"symfony/css-selector": "^5.4",
"symfony/browser-kit": "^5.4|^6.4",
"symfony/dom-crawler": "^5.4|^6.4",
"symfony/css-selector": "^5.4|^6.4",
"doctrine/orm": "^2.8",
"doctrine/doctrine-bundle": "^2.4",
"ornicar/akismet-bundle": "dev-master",
"symfony/expression-language": "^5.4",
"symfony/phpunit-bridge": "^5.4",
"symfony/expression-language": "^5.4|^6.4",
"symfony/phpunit-bridge": "^5.4|^6.4",
"phpunit/phpunit": "^9.4",
"sonata-project/user-bundle": "^5.10",
"symfony/process": "^6.4"
Expand Down
1 change: 0 additions & 1 deletion tests/Functional/ApiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ public function testGetEmptyThread($id)
public function testAddCommentToThread($id)
{
$crawler = $this->client->request('GET', "/comment_api/threads/{$id}/comments/new.html");

$form = $crawler->selectButton('fos_comment_comment_new_submit')->form();
$form['fos_comment_comment[body]'] = 'Test Comment';
$this->client->submit($form);
Expand Down
1 change: 1 addition & 0 deletions tests/Functional/Bundle/CommentBundle/CommentBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace FOS\CommentBundle\Tests\Functional\Bundle\CommentBundle;


use Symfony\Component\HttpKernel\Bundle\Bundle;

class CommentBundle extends Bundle
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,26 @@

namespace FOS\CommentBundle\Tests\Functional\Bundle\CommentBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

/**
* Test controller used in the functional tests for CommentBundle.
*
* @author Tim Nagel <[email protected]>
*/
class CommentController extends Controller
class CommentController extends AbstractController
{
public function asyncAction($id)
public function asyncAction($id): Response
{
return $this->render('CommentBundle:Comment:async.html.twig', [
'id' => $id,
]);
}

public function inlineAction(Request $request, $id)
public function inlineAction(Request $request, $id): Response
{
$thread = $this->container->get('fos_comment.manager.thread')->findThreadById($id);
if (null === $thread) {
Expand Down
98 changes: 24 additions & 74 deletions tests/Functional/Bundle/CommentBundle/Entity/Comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,117 +18,67 @@
use FOS\CommentBundle\Model\VotableCommentInterface;
use Symfony\Component\Security\Core\User\UserInterface;

/**
* @ORM\Entity
* @ORM\Table(name="test_comment")
* @ORM\ChangeTrackingPolicy("DEFERRED_EXPLICIT")
*
* @author Tim Nagel <[email protected]>
*/
#[ORM\Entity]
#[ORM\Table(name: 'test_comment')]
#[ORM\ChangeTrackingPolicy('DEFERRED_EXPLICIT')]
class Comment extends BaseComment implements SignedCommentInterface, VotableCommentInterface
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
#[ORM\Column(name: 'id', type: 'integer')]
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'AUTO')]
protected $id;

/**
* Thread of this comment.
*
* @ORM\ManyToOne(targetEntity="Thread")
*
* @var Thread
*/

#[ORM\ManyToOne(targetEntity: Thread::class)]
protected $thread;

/**
* @ORM\Column(type="string", nullable=true)
*
* @var string
*/

#[ORM\Column(type: 'string', nullable: true)]
protected $author;

/**
* @ORM\Column(type="integer")
*
* @var int
*/

#[ORM\Column(type: 'integer')]
protected $score = 0;

/**
* @return Thread
*/
public function getThread()

public function getThread(): Thread
{
return $this->thread;
}

/**
* @param Thread $thread
*
* @return null
*/
public function setThread(ThreadInterface $thread)
public function setThread(ThreadInterface $thread): void
{
$this->thread = $thread;
}

/**
* Sets the author of the Comment.
*
* @param string $user
*/
public function setAuthor(UserInterface $author)

public function setAuthor(UserInterface $author): void
{
$this->author = $author->getUsername();
$this->author = method_exists($author, 'getUsername') ? $author->getUsername() : $author->getUserIdentifier();

}

/**
* Gets the author of the Comment.
*
* @return string
*/
public function getAuthor()
public function getAuthor(): ?string
{
return $this->author;
}

/**
* Sets the score of the comment.
*
* @param int $score
*/
public function setScore($score)
public function setScore($score): void
{
$this->score = $score;
}

/**
* Returns the current score of the comment.
*
* @return int
*/
public function getScore()
public function getScore(): int
{
return $this->score;
}

/**
* Increments the comment score by the provided
* value.
*
* @param int value
*
* @return int The new comment score
*/
public function incrementScore($by = 1)
public function incrementScore($by = 1): void
{
$this->score += $by;
}

public function getAuthorName()
public function getAuthorName(): string
{
return $this->author ?: parent::getAuthorName();
}
Expand Down
22 changes: 7 additions & 15 deletions tests/Functional/Bundle/CommentBundle/Entity/Thread.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,21 @@
use Doctrine\ORM\Mapping as ORM;
use FOS\CommentBundle\Entity\Thread as BaseThread;

/**
* @ORM\Entity
* @ORM\Table(name="test_thread")
* @ORM\ChangeTrackingPolicy("DEFERRED_EXPLICIT")
*
* @author Tim Nagel <[email protected]>
*/
#[ORM\Entity]
#[ORM\Table(name: 'test_thread')]
#[ORM\ChangeTrackingPolicy('DEFERRED_EXPLICIT')]
class Thread extends BaseThread
{
/**
* @var string
*
* @ORM\Id
* @ORM\Column(type="string")
*/
#[ORM\Id]
#[ORM\Column(type: 'string')]
protected $id;

public function getId()
public function getId(): ?string
{
return $this->id;
}

public function setId($id)
public function setId($id): void
{
$this->id = $id;
}
Expand Down
42 changes: 14 additions & 28 deletions tests/Functional/Bundle/CommentBundle/Entity/Vote.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,43 +16,29 @@
use FOS\CommentBundle\Model\SignedVoteInterface;
use Symfony\Component\Security\Core\User\UserInterface;

/**
* @ORM\Entity
* @ORM\Table(name="test_vote")
* @ORM\ChangeTrackingPolicy("DEFERRED_EXPLICIT")
*/
#[ORM\Entity]
#[ORM\Table(name: 'test_vote')]
#[ORM\ChangeTrackingPolicy('DEFERRED_EXPLICIT')]
class Vote extends BaseVote implements SignedVoteInterface
{
/**
* @var int
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/

#[ORM\Column(name: 'id', type: 'integer')]
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'AUTO')]
protected $id;

/**
* @var string
* @ORM\Column(type="string")
*/

#[ORM\Column(type: 'string')]
protected $voter;

/**
* Sets the owner of the vote.
*
* @param string $user
*/
public function setVoter(UserInterface $voter)

public function setVoter(UserInterface $voter): void
{
$this->voter = $voter->getUsername();
$this->voter = method_exists($voter, 'getUsername') ? $voter->getUsername() : $voter->getUserIdentifier();
}

/**
* Gets the owner of the vote.
*
* @return UserInterface
*/
public function getVoter()

public function getVoter(): UserInterface
{
return $this->voter;
}
Expand Down
27 changes: 4 additions & 23 deletions tests/Functional/WebTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace FOS\CommentBundle\Tests\Functional;

use Doctrine\ORM\Mapping\ClassMetadata;
use Doctrine\ORM\Tools\SchemaTool;
use Doctrine\Persistence\ObjectManager;
use Symfony\Bundle\FrameworkBundle\KernelBrowser;
Expand All @@ -29,16 +30,10 @@
class WebTestCase extends BaseWebTestCase
{
use WebTestAssertionsTrait;
/**
* @var ObjectManager
*/
protected $em;
protected static $schemaSetUp = false;

/**
* @var AbstractBrowser
*/
protected $client;
protected ?ObjectManager $em = null;
protected static bool $schemaSetUp = false;
protected ?AbstractBrowser $client = null;

protected function setUp(): void
{
Expand Down Expand Up @@ -83,20 +78,6 @@ protected static function createClient(array $options = [], array $server = []):
return $client;
}

protected static function bootKernel(array $options = []): KernelInterface
{
static::ensureKernelShutdown();

$kernel = static::createKernel($options);
$kernel->boot();
static::$kernel = $kernel;
static::$booted = true;

$container = static::$kernel->getContainer();
static::$container = $container->has('test.service_container') ? $container->get('test.service_container') : $container;

return static::$kernel;
}
protected static function createKernel(array $options = []): KernelInterface
{

Expand Down
Loading

0 comments on commit 95448aa

Please sign in to comment.