From 0d202c5ab65b2b025969baf88d7cac162f087833 Mon Sep 17 00:00:00 2001 From: Alexis Lefebvre Date: Sat, 17 Nov 2018 18:30:21 +0100 Subject: [PATCH 1/4] Travis CI: Add analysis stage --- .travis.yml | 120 ++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 92 insertions(+), 28 deletions(-) diff --git a/.travis.yml b/.travis.yml index 949f319..cd2162d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,12 @@ dist: trusty -sudo: false + +sudo: required language: php +services: + - docker + git: depth: 5 @@ -12,30 +16,90 @@ cache: php: - 7.1 - - 7.2 - -env: - - SYMFONY_VERSION="3.4.*" - - SYMFONY_VERSION="~4.1" - -# Only send code coverage to Code Climate for the current versions of PHP and Symfony LTS -# https://github.com/doctrine/doctrine2/blob/3570f4a49afc7e98fed71e0596dded6a39d4fd7b/.travis.yml#L16 -before_install: - - if echo "$TRAVIS_COMMIT_MESSAGE" | grep -F -q "[skip travis]" ; then echo "[skip travis] has been found, exiting" && exit 0 ; else echo "[skip travis] has not been found, continuing" ; fi - - if [[ $TRAVIS_PHP_VERSION = '7.2' && $SYMFONY_VERSION = '3.4.*' ]]; then DEPENDENCY="codeclimate/php-test-reporter:~0.3 satooshi/php-coveralls:~1.0"; PHPUNIT_FLAGS="--coverage-clover ./build/logs/clover.xml"; else DEPENDENCY=""; PHPUNIT_FLAGS=""; fi - - if [[ $PHPUNIT_FLAGS = "" ]]; then phpenv config-rm xdebug.ini; fi - -install: - - if [[ $SYMFONY_VERSION = '3.4.*' ]]; then composer require symfony/lts:v3 --no-update; fi - - composer require symfony/config:${SYMFONY_VERSION} symfony/form:${SYMFONY_VERSION} symfony/framework-bundle:${SYMFONY_VERSION} symfony/templating:${SYMFONY_VERSION} symfony/security-csrf:${SYMFONY_VERSION} symfony/var-dumper:${SYMFONY_VERSION} $DEPENDENCY --no-update - - composer install --no-interaction --profile --no-progress - -script: - - php ./vendor/bin/phpspec run --format=pretty - - php ./vendor/bin/phpunit $PHPUNIT_FLAGS - - php ./vendor/bin/behat - -# Only send code coverage if it has been generated -after_success: - - if [[ $PHPUNIT_FLAGS != "" ]]; then php ./vendor/bin/test-reporter; fi - - if [[ $PHPUNIT_FLAGS != "" ]]; then travis_retry php vendor/bin/coveralls -v --config .coveralls.yml; fi + +stages: + - analysis + - test + +jobs: + include: + - stage: analysis + name: "php-cs-fixer" + before_install: + - docker pull jakzal/phpqa + script: + - docker run --volume $PWD:/app --workdir /app jakzal/phpqa:alpine php-cs-fixer fix src/ --dry-run + - name: "phpstan" + script: + - docker run --volume $PWD:/app --workdir /app jakzal/phpqa:alpine phpstan analyse --level 6 src/ --no-progress + + - stage: test + name: "PHP 7.1 / Symfony 3.4" + php: 7.1 + env: + - SYMFONY_VERSION="3.4.*" + before_install: + - phpenv config-rm xdebug.ini + + install: + - composer require symfony/lts:v3 --no-update + - composer require symfony/config:${SYMFONY_VERSION} symfony/form:${SYMFONY_VERSION} symfony/framework-bundle:${SYMFONY_VERSION} symfony/templating:${SYMFONY_VERSION} symfony/security-csrf:${SYMFONY_VERSION} symfony/var-dumper:${SYMFONY_VERSION} --no-update + - composer install --no-interaction --profile --no-progress + + script: + - php ./vendor/bin/phpspec run --format=pretty + - php ./vendor/bin/phpunit $PHPUNIT_FLAGS + - php ./vendor/bin/behat + - name: "PHP 7.2 / Symfony 3.4 / Code coverage" + php: 7.2 + env: + - SYMFONY_VERSION="3.4.*" + # Only send code coverage to Code Climate for the current versions of PHP and Symfony LTS + # https://github.com/doctrine/doctrine2/blob/3570f4a49afc7e98fed71e0596dded6a39d4fd7b/.travis.yml#L16 + before_install: + - DEPENDENCY="codeclimate/php-test-reporter:~0.3 satooshi/php-coveralls:~1.0" + + install: + - composer require symfony/lts:v3 --no-update + - composer require symfony/config:${SYMFONY_VERSION} symfony/form:${SYMFONY_VERSION} symfony/framework-bundle:${SYMFONY_VERSION} symfony/templating:${SYMFONY_VERSION} symfony/security-csrf:${SYMFONY_VERSION} symfony/var-dumper:${SYMFONY_VERSION} $DEPENDENCY --no-update + - composer install --no-interaction --profile --no-progress + + script: + - php ./vendor/bin/phpspec run --format=pretty + - php ./vendor/bin/phpunit --coverage-clover ./build/logs/clover.xml + - php ./vendor/bin/behat + + after_success: + - php ./vendor/bin/test-reporter + - travis_retry php vendor/bin/coveralls -v --config .coveralls.yml + - name: "PHP 7.1 / Symfony 4" + php: 7.1 + env: + - SYMFONY_VERSION="^4.1" + before_install: + - phpenv config-rm xdebug.ini + + install: + - composer require symfony/config:${SYMFONY_VERSION} symfony/form:${SYMFONY_VERSION} symfony/framework-bundle:${SYMFONY_VERSION} symfony/templating:${SYMFONY_VERSION} symfony/security-csrf:${SYMFONY_VERSION} symfony/var-dumper:${SYMFONY_VERSION} --no-update + - composer install --no-interaction --profile --no-progress + + script: + - php ./vendor/bin/phpspec run --format=pretty + - php ./vendor/bin/phpunit $PHPUNIT_FLAGS + - php ./vendor/bin/behat + - name: "PHP 7.2 / Symfony 4" + php: 7.2 + env: + - SYMFONY_VERSION="^4.1" + before_install: + - phpenv config-rm xdebug.ini + + install: + - composer require symfony/config:${SYMFONY_VERSION} symfony/form:${SYMFONY_VERSION} symfony/framework-bundle:${SYMFONY_VERSION} symfony/templating:${SYMFONY_VERSION} symfony/security-csrf:${SYMFONY_VERSION} symfony/var-dumper:${SYMFONY_VERSION} --no-update + - composer install --no-interaction --profile --no-progress + + script: + - php ./vendor/bin/phpspec run --format=pretty + - php ./vendor/bin/phpunit $PHPUNIT_FLAGS + - php ./vendor/bin/behat + From b80d2ab874ea3ccc46f227029d335bbfb9cbeb3f Mon Sep 17 00:00:00 2001 From: Alexis Lefebvre Date: Sat, 17 Nov 2018 18:41:11 +0100 Subject: [PATCH 2/4] PHP-CS-Fixer --- src/Command/StatusesHomeTimelineCommand.php | 45 +++++++++++++-------- src/Command/StatusesReadCommand.php | 28 ++++++++----- src/Controller/DefaultController.php | 10 +++-- src/Utils/PersistTweet.php | 8 ++-- 4 files changed, 60 insertions(+), 31 deletions(-) diff --git a/src/Command/StatusesHomeTimelineCommand.php b/src/Command/StatusesHomeTimelineCommand.php index b7334f8..bee3610 100644 --- a/src/Command/StatusesHomeTimelineCommand.php +++ b/src/Command/StatusesHomeTimelineCommand.php @@ -30,8 +30,12 @@ protected function configure() ->setName('statuses:hometimeline') ->setDescription('Fetch home timeline') // http://symfony.com/doc/2.3/cookbook/console/console_command.html#automatically-registering-commands - ->addOption('table', null, InputOption::VALUE_NONE, - 'Display a table with tweets'); + ->addOption( + 'table', + null, + InputOption::VALUE_NONE, + 'Display a table with tweets' + ); } /** @@ -107,9 +111,10 @@ protected function getContent(InputInterface $input) * @param OutputInterface $output * @param null|object $content */ - protected function displayContentNotArrayError(OutputInterface $output, - $content) - { + protected function displayContentNotArrayError( + OutputInterface $output, + $content + ) { $formatter = $this->getHelper('formatter'); $errorMessages = ['Error!', 'Something went wrong, $content is not an array.']; @@ -124,9 +129,12 @@ protected function displayContentNotArrayError(OutputInterface $output, * @param array $content * @param int $numberOfTweets */ - protected function addAndDisplayTweets(InputInterface $input, - OutputInterface $output, $content, $numberOfTweets) - { + protected function addAndDisplayTweets( + InputInterface $input, + OutputInterface $output, + $content, + $numberOfTweets + ) { $output->writeln('Number of tweets: '.$numberOfTweets.''); // Iterate through $content in order to add the oldest tweet first, @@ -150,9 +158,10 @@ protected function addAndDisplayTweets(InputInterface $input, * @param OutputInterface $output * @param int $numberOfTweets */ - protected function setProgressBar(OutputInterface $output, - $numberOfTweets) - { + protected function setProgressBar( + OutputInterface $output, + $numberOfTweets + ) { $this->progress = new ProgressBar($output, $numberOfTweets); $this->progress->setBarCharacter('='); $this->progress->start(); @@ -162,9 +171,10 @@ protected function setProgressBar(OutputInterface $output, * @param InputInterface $input * @param OutputInterface $output */ - protected function setTable(InputInterface $input, - OutputInterface $output) - { + protected function setTable( + InputInterface $input, + OutputInterface $output + ) { $this->displayTable = $input->getOption('table'); // Display @@ -180,8 +190,11 @@ protected function setTable(InputInterface $input, */ protected function iterateTweets($tweets) { - $persistTweet = new PersistTweet($this->em, $this->displayTable, - $this->table); + $persistTweet = new PersistTweet( + $this->em, + $this->displayTable, + $this->table + ); foreach ($tweets as $tweetTmp) { $persistTweet->addTweet($tweetTmp, true); diff --git a/src/Command/StatusesReadCommand.php b/src/Command/StatusesReadCommand.php index ca287cd..1083b96 100644 --- a/src/Command/StatusesReadCommand.php +++ b/src/Command/StatusesReadCommand.php @@ -55,18 +55,26 @@ protected function execute(InputInterface $input, OutputInterface $output) * @param OutputInterface $output * @param array $tweets */ - protected function displayTweets(OutputInterface $output, - $tweets) - { + protected function displayTweets( + OutputInterface $output, + $tweets + ) { $this->setTable($output); foreach ($tweets as $tweet) { - $this->table->addRows([ + $this->table->addRows( + [ [ - $this->formatCell('info', - $tweet->getUser()->getName(), 13), - $this->formatCell('comment', - $tweet->getText(), 40), + $this->formatCell( + 'info', + $tweet->getUser()->getName(), + 13 + ), + $this->formatCell( + 'comment', + $tweet->getText(), + 40 + ), $tweet->getCreatedAt()->format('Y-m-d H:i'), ], // empty row between tweets @@ -101,7 +109,9 @@ protected function formatCell($tag, $content, $length) { return '<'.$tag.'>'. // Close and reopen the tag before each new line - str_replace("\n", '\n<".$tag.'>', + str_replace( + "\n", + '\n<".$tag.'>', wordwrap($content, $length, "\n") ). ''; diff --git a/src/Controller/DefaultController.php b/src/Controller/DefaultController.php index dd83031..31b78b6 100644 --- a/src/Controller/DefaultController.php +++ b/src/Controller/DefaultController.php @@ -124,8 +124,11 @@ private function createCookie($firstTweetId) $nextYear->add(new \DateInterval('P1Y')); // Set last Tweet Id - $cookie = new Cookie('lastTweetId', $firstTweetId, - $nextYear->format('U')); + $cookie = new Cookie( + 'lastTweetId', + $firstTweetId, + $nextYear->format('U') + ); return $cookie; } @@ -161,7 +164,8 @@ public function deleteLessThanAction(Request $request) ->getRepository('AsyncTweetsBundle:Tweet') ->deleteAndHideTweetsLessThanId($lastTweetId); - $this->get('session')->getFlashBag()->add('message', + $this->get('session')->getFlashBag()->add( + 'message', sprintf('%s tweets deleted.', $count) ); } diff --git a/src/Utils/PersistTweet.php b/src/Utils/PersistTweet.php index f19a94b..1d4aa20 100644 --- a/src/Utils/PersistTweet.php +++ b/src/Utils/PersistTweet.php @@ -98,9 +98,11 @@ protected function createTweet(\stdClass $tweetTmp, $user, $inTimeline) * * @return Tweet */ - protected function persistTweet(\stdClass $tweetTmp, User $user, - $inTimeline) - { + protected function persistTweet( + \stdClass $tweetTmp, + User $user, + $inTimeline + ) { $tweet = $this->em ->getRepository('AsyncTweetsBundle:Tweet') ->findOneById($tweetTmp->id); From 5b6eff262358311b481cf39d057d37b13dda4dfb Mon Sep 17 00:00:00 2001 From: Alexis Lefebvre Date: Sat, 17 Nov 2018 18:59:19 +0100 Subject: [PATCH 3/4] PHPStan --- .travis.yml | 2 ++ src/Command/BaseCommand.php | 6 +++-- src/Command/StatusesReadCommand.php | 6 ++++- src/Command/StatusesShowCommand.php | 11 ++++++--- src/Controller/DefaultController.php | 34 ++++++++++++++++++++-------- src/Entity/Tweet.php | 8 +++---- src/Entity/User.php | 6 ++--- 7 files changed, 48 insertions(+), 25 deletions(-) diff --git a/.travis.yml b/.travis.yml index cd2162d..08676fc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,6 +30,8 @@ jobs: script: - docker run --volume $PWD:/app --workdir /app jakzal/phpqa:alpine php-cs-fixer fix src/ --dry-run - name: "phpstan" + install: + - composer install --no-interaction --profile --no-progress script: - docker run --volume $PWD:/app --workdir /app jakzal/phpqa:alpine phpstan analyse --level 6 src/ --no-progress diff --git a/src/Command/BaseCommand.php b/src/Command/BaseCommand.php index 7b8e711..2933519 100644 --- a/src/Command/BaseCommand.php +++ b/src/Command/BaseCommand.php @@ -2,6 +2,7 @@ namespace AlexisLefebvre\Bundle\AsyncTweetsBundle\Command; +use Symfony\Bridge\Doctrine\ManagerRegistry; use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -27,7 +28,8 @@ protected function initialize(InputInterface $input, OutputInterface $output) $this->container = $this->getContainer(); // This loads Doctrine, you can load your own services as well - $this->em = $this->container->get('doctrine') - ->getManager(); + /** @var ManagerRegistry $doctrine */ + $doctrine = $this->container->get('doctrine'); + $this->em = $doctrine->getManager(); } } diff --git a/src/Command/StatusesReadCommand.php b/src/Command/StatusesReadCommand.php index 1083b96..8fe840e 100644 --- a/src/Command/StatusesReadCommand.php +++ b/src/Command/StatusesReadCommand.php @@ -29,13 +29,17 @@ protected function configure() */ protected function execute(InputInterface $input, OutputInterface $output) { + /** @var int|null $page */ $page = $input->getArgument('page'); if ($page < 1) { $page = 1; } - $output->writeln('Current page: '.$page.''); + $output->writeln(sprintf( + 'Current page: %d', + $page + )); // Get the tweets $tweets = $this->em diff --git a/src/Command/StatusesShowCommand.php b/src/Command/StatusesShowCommand.php index 32dd7a7..eddc0ba 100644 --- a/src/Command/StatusesShowCommand.php +++ b/src/Command/StatusesShowCommand.php @@ -25,6 +25,7 @@ protected function configure() */ protected function execute(InputInterface $input, OutputInterface $output) { + /** @var int|null $tweet_id */ $tweet_id = $input->getArgument('tweet_id'); $connection = new TwitterOAuth( @@ -34,8 +35,12 @@ protected function execute(InputInterface $input, OutputInterface $output) $this->container->getParameter('twitter_token_secret') ); - $output->writeln( - json_encode($connection->get('statuses/show/'.$tweet_id)) - ); + /** @var string $json */ + $json = json_encode($connection->get(sprintf( + 'statuses/show/%d', + $tweet_id + ))); + + $output->writeln($json); } } diff --git a/src/Controller/DefaultController.php b/src/Controller/DefaultController.php index 31b78b6..b7b699c 100644 --- a/src/Controller/DefaultController.php +++ b/src/Controller/DefaultController.php @@ -2,13 +2,17 @@ namespace AlexisLefebvre\Bundle\AsyncTweetsBundle\Controller; +use AlexisLefebvre\Bundle\AsyncTweetsBundle\Entity\Tweet; +use AlexisLefebvre\Bundle\AsyncTweetsBundle\Entity\TweetRepository; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Component\HttpFoundation\Cookie; use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Session\Session; class DefaultController extends Controller { + /** @var TweetRepository */ private $tweetRepository; /** @@ -19,9 +23,12 @@ class DefaultController extends Controller */ public function indexAction(Request $request, $firstTweetId = null) { - $this->tweetRepository = $this->getDoctrine() + /** @var TweetRepository $tweetRepository */ + $tweetRepository = $this->getDoctrine() ->getRepository('AsyncTweetsBundle:Tweet'); + $this->tweetRepository = $tweetRepository; + $tweets = $this->tweetRepository ->getWithUsersAndMedias($firstTweetId); @@ -43,9 +50,9 @@ public function indexAction(Request $request, $firstTweetId = null) } /** - * @param Request $request - * @param Tweets[] $tweets - * @param int $firstTweetId + * @param Request $request + * @param Tweet[] $tweets + * @param string $firstTweetId * * @return array $vars */ @@ -71,13 +78,14 @@ private function getVariables(Request $request, $tweets, $firstTweetId) /** * If a Tweet is displayed, fetch data from repository. * - * @param Tweets[] $tweets - * @param array $vars + * @param Tweet[] $tweets + * @param array $vars * * @return array $vars */ private function getTweetsVars($tweets, $vars) { + /** @var string $firstTweetId */ $firstTweetId = $tweets[0]->getId(); $vars['previous'] = $this->tweetRepository @@ -120,7 +128,7 @@ private function getLastTweetIdFromCookie(Request $request) */ private function createCookie($firstTweetId) { - $nextYear = new \Datetime('now'); + $nextYear = new \DateTime('now'); $nextYear->add(new \DateInterval('P1Y')); // Set last Tweet Id @@ -160,11 +168,17 @@ public function deleteLessThanAction(Request $request) $lastTweetId = $this->getLastTweetIdFromCookie($request); if (!is_null($lastTweetId)) { - $count = $this->getDoctrine() - ->getRepository('AsyncTweetsBundle:Tweet') + /** @var TweetRepository $tweetRepository */ + $tweetRepository = $this->getDoctrine() + ->getRepository('AsyncTweetsBundle:Tweet'); + + $count = $tweetRepository ->deleteAndHideTweetsLessThanId($lastTweetId); - $this->get('session')->getFlashBag()->add( + /** @var Session $session */ + $session = $this->get('session'); + + $session->getFlashBag()->add( 'message', sprintf('%s tweets deleted.', $count) ); diff --git a/src/Entity/Tweet.php b/src/Entity/Tweet.php index 139ba28..13dcb65 100644 --- a/src/Entity/Tweet.php +++ b/src/Entity/Tweet.php @@ -72,11 +72,9 @@ public function __construct($id = null) /** * Set id. * - * @param bigint $id - * * @return Tweet */ - public function setId($id) + public function setId(int $id) { $this->id = $id; @@ -100,7 +98,7 @@ public function getId() * * @return Tweet */ - public function setCreatedAt(\Datetime $createdAt) + public function setCreatedAt(\DateTime $createdAt) { $this->created_at = $createdAt; @@ -334,7 +332,7 @@ public function getRetweetingStatuses() public function setValues(\stdClass $tweetTmp) { $this - ->setCreatedAt(new \Datetime($tweetTmp->created_at)) + ->setCreatedAt(new \DateTime($tweetTmp->created_at)) ->setText($tweetTmp->text) ->setRetweetCount($tweetTmp->retweet_count) ->setFavoriteCount($tweetTmp->favorite_count); diff --git a/src/Entity/User.php b/src/Entity/User.php index 3d9d30d..8999591 100644 --- a/src/Entity/User.php +++ b/src/Entity/User.php @@ -30,7 +30,7 @@ class User private $profile_image_url; /** - * @var string + * @var string|null */ private $profile_image_url_https; @@ -160,10 +160,8 @@ public function setProfileImageUrlHttps($profileImageUrlHttps) /** * Get profile_image_url_https. - * - * @return string */ - public function getProfileImageUrlHttps() + public function getProfileImageUrlHttps(): ?string { return $this->profile_image_url_https; } From 631b9fadec182fa76bb9ac8b2ff6b3211c711842 Mon Sep 17 00:00:00 2001 From: Alexis Lefebvre Date: Sat, 17 Nov 2018 21:26:32 +0100 Subject: [PATCH 4/4] Remove id argument from Tweet::__construct() --- src/Entity/Tweet.php | 6 +----- src/Utils/PersistTweet.php | 3 ++- tests/DataFixtures/ORM/LoadTweetAndRetweetData.php | 3 ++- tests/DataFixtures/ORM/LoadTweetData.php | 3 ++- tests/DataFixtures/ORM/LoadTweetPagesData.php | 6 ++++-- tests/Entity/TweetTest.php | 3 ++- tests/Features/Context/FeatureContext.php | 3 ++- 7 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/Entity/Tweet.php b/src/Entity/Tweet.php index 13dcb65..557d1c2 100644 --- a/src/Entity/Tweet.php +++ b/src/Entity/Tweet.php @@ -59,12 +59,8 @@ class Tweet */ private $medias; - public function __construct($id = null) + public function __construct() { - if (!is_null($id)) { - $this->setId($id); - } - $this->medias = new ArrayCollection(); $this->retweeting_statuses = new ArrayCollection(); } diff --git a/src/Utils/PersistTweet.php b/src/Utils/PersistTweet.php index 1d4aa20..dee1add 100644 --- a/src/Utils/PersistTweet.php +++ b/src/Utils/PersistTweet.php @@ -79,9 +79,10 @@ protected function addMedias(\stdClass $tweetTmp, Tweet $tweet) */ protected function createTweet(\stdClass $tweetTmp, $user, $inTimeline) { - $tweet = new Tweet($tweetTmp->id); + $tweet = new Tweet(); $tweet + ->setId($tweetTmp->id) ->setValues($tweetTmp) ->setUser($user) ->setInTimeline($inTimeline); diff --git a/tests/DataFixtures/ORM/LoadTweetAndRetweetData.php b/tests/DataFixtures/ORM/LoadTweetAndRetweetData.php index 3b3bcd5..67c2e98 100644 --- a/tests/DataFixtures/ORM/LoadTweetAndRetweetData.php +++ b/tests/DataFixtures/ORM/LoadTweetAndRetweetData.php @@ -14,8 +14,9 @@ class LoadTweetAndRetweetData extends AbstractFixture implements DependentFixtur */ public function load(ObjectManager $manager) { - $tweet = new Tweet(10); + $tweet = new Tweet(); $tweet + ->setId(10) ->setUser($this->getReference('user')) ->setCreatedAt(new \Datetime('2015-02-10 21:19:20')) ->setText('Hello Twitter! #myfirstTweet') diff --git a/tests/DataFixtures/ORM/LoadTweetData.php b/tests/DataFixtures/ORM/LoadTweetData.php index 0db8117..b37b8c6 100644 --- a/tests/DataFixtures/ORM/LoadTweetData.php +++ b/tests/DataFixtures/ORM/LoadTweetData.php @@ -14,8 +14,9 @@ class LoadTweetData extends AbstractFixture implements DependentFixtureInterface */ public function load(ObjectManager $manager) { - $tweet = new Tweet(49664); + $tweet = new Tweet(); $tweet + ->setId(49664) ->setUser($this->getReference('user')) ->setCreatedAt(new \Datetime('2015-02-10 21:19:20')) ->setText('Hello Twitter! #myfirstTweet') diff --git a/tests/DataFixtures/ORM/LoadTweetPagesData.php b/tests/DataFixtures/ORM/LoadTweetPagesData.php index 5bbd181..e4cd334 100644 --- a/tests/DataFixtures/ORM/LoadTweetPagesData.php +++ b/tests/DataFixtures/ORM/LoadTweetPagesData.php @@ -17,8 +17,9 @@ public function load(ObjectManager $manager) $tweetId = 1; // Add retweeted Tweet - $retweeted = new Tweet($tweetId); + $retweeted = new Tweet(); $retweeted + ->setId($tweetId) ->setUser($this->getReference('user-githubeng')) ->setCreatedAt(new \Datetime( '2015-02-10 21:18:'.sprintf('%02d', $tweetId))) @@ -30,8 +31,9 @@ public function load(ObjectManager $manager) // not retweet tweets foreach (range(2, 40) as $tweetId) { - $tweet = new Tweet($tweetId); + $tweet = new Tweet(); $tweet + ->setId($tweetId) ->setUser($this->getReference('user')) ->setCreatedAt( new \Datetime('2015-02-10 21:19:'.sprintf('%02d', $tweetId))) diff --git a/tests/Entity/TweetTest.php b/tests/Entity/TweetTest.php index 9fa04fd..0f9e604 100644 --- a/tests/Entity/TweetTest.php +++ b/tests/Entity/TweetTest.php @@ -21,8 +21,9 @@ public function testTweet() ->setExpandedUrl('http://twitter.com/AsyncTweets/status/567836201210900480/photo/1'); // Tweet - $tweet = new Tweet(152120320); + $tweet = new Tweet(); $tweet + ->setId(152120320) ->setCreatedAt($now) ->setText('Hello World!') ->setRetweetCount(1999) diff --git a/tests/Features/Context/FeatureContext.php b/tests/Features/Context/FeatureContext.php index a524ab2..9224238 100644 --- a/tests/Features/Context/FeatureContext.php +++ b/tests/Features/Context/FeatureContext.php @@ -26,8 +26,9 @@ public function thereIsATweet() { $this->now = new \Datetime('now'); - $this->tweet = new Tweet(152120320); + $this->tweet = new Tweet(); $this->tweet + ->setId(152120320) ->setCreatedAt($this->now) ->setText('Hello World!') ->setRetweetCount(1999)