diff --git a/.scrutinizer.yml b/.scrutinizer.yml
index dac9e20..e394324 100644
--- a/.scrutinizer.yml
+++ b/.scrutinizer.yml
@@ -16,7 +16,7 @@ build:
dependencies:
override:
-
- command: 'composer require --dev "symfony/symfony:3.4.*" --no-update'
+ command: 'composer require "symfony/symfony:3.4.*" --no-update'
-
command: 'composer install --no-interaction -vv --profile --no-progress'
idle_timeout: 900
diff --git a/.travis.yml b/.travis.yml
index 1dee0c0..949f319 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -16,6 +16,7 @@ php:
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
@@ -25,7 +26,8 @@ before_install:
- if [[ $PHPUNIT_FLAGS = "" ]]; then phpenv config-rm xdebug.ini; fi
install:
- - composer require --dev symfony/symfony:${SYMFONY_VERSION} $DEPENDENCY --no-update
+ - 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:
diff --git a/README.md b/README.md
index 154b5ea..6cfd0de 100644
--- a/README.md
+++ b/README.md
@@ -46,11 +46,11 @@ This bundle is also used to test several CI (Continuous Integration) services.
### Requirements:
- [Twitter keys][Twitter keys]
- - PHP >= 5.5 (required by abraham/twitteroauth 0.6.0)
+ - PHP >= 7.1
- a database (must be supported by Doctrine2)
- - [Symfony][Symfony GitHub] (2.7 or higher) with [Composer][Composer]. If you want to install it:
+ - [Symfony][Symfony GitHub] (3.4+) with [Composer][Composer]. If you want to install it:
- php composer.phar create-project symfony/framework-standard-edition YOUR_DIRECTORY "2.7.*" -vvv
+ php composer.phar create-project symfony/framework-standard-edition YOUR_DIRECTORY "3.4.*" -vvv
### Steps:
@@ -79,49 +79,24 @@ This bundle is also used to test several CI (Continuous Integration) services.
### Usage:
1. Launch this command to fetch tweets: `php app/console statuses:hometimeline --table --env=prod`, with the ` --table` option the imported tweets will be shown
- 2. Update app/config/config.yml to enable Assetic if it's not activated yet:
-
- framework:
- # ...
- assets: ~
-
- 3. Import the routes in your app/config/routing.yml:
+ 2. Import the routes in your app/config/routing.yml:
asynctweets_website:
resource: "@AsyncTweetsBundle/Resources/config/routing.yml"
prefix: /asynctweets # Use only "/" if you want AsyncTweets at the root of the website
- 4. Open the page with your browser `.../YOUR_DIRECTORY/web/asynctweets/` or use the following command `php app/console statuses:read --env=prod` to see tweets
-
- 5. If you have an error `An exception has been thrown during the compilation of a template ("You must add AsyncTweetsBundle to the assetic.bundle config to use the {% image %} tag in AsyncTweetsBundle::layout.html.twig.") in "AsyncTweetsBundle::layout.html.twig".`, add the bundle in assetic bundles:
-
- # Assetic Configuration
- assetic:
- # ...
- bundles: [ AsyncTweetsBundle ]
-
- 6. Add `php app/console statuses:hometimeline --env=prod` in your crontab (e.g. every hour) to retrieve tweets automatically
+ 3. Open the page with your browser `.../YOUR_DIRECTORY/web/asynctweets/` or use the following command `php app/console statuses:read --env=prod` to see tweets
+ 4. Add `php app/console statuses:hometimeline --env=prod` in your crontab (e.g. every hour) to retrieve tweets automatically
## Dependencies
- - [symfony/symfony][Symfony GitHub] (2.7+)
+ - [symfony/symfony][Symfony GitHub] (3.4+)
- [abraham/twitteroauth][twitteroauth] (^0.6.0)
- [twitter/bootstrap][Twitter Bootstrap] (use [Bootswatch 3.3.2][Bootstrap CDN])
### Tests:
-If `phpunit` is installed:
-
- phpunit
-
-Or by installing `phpunit` with Composer:
-
- php composer.phar require --dev phpunit/phpunit "4.8.* || 5.1.*" -vvv ; php vendor/bin/phpunit
-
-### Development environment
-
- - [doctrine/doctrine-fixtures-bundle][doctrine-fixtures-bundle] (~2.3)
- - [liip/functional-test-bundle][functional-test-bundle] (~1.0)
+ php vendor/bin/phpunit
[Packagist]: https://packagist.org/packages/alexislefebvre/async-tweets-bundle
[Packagist Stable Image]: https://poser.pugx.org/alexislefebvre/async-tweets-bundle/v/stable.svg
@@ -159,5 +134,3 @@ Or by installing `phpunit` with Composer:
[twitteroauth]: https://github.com/abraham/twitteroauth
[Twitter Bootstrap]: https://github.com/twbs/bootstrap
[Bootstrap CDN]: http://www.bootstrapcdn.com/#bootswatch_tab
-[doctrine-fixtures-bundle]: https://github.com/doctrine/DoctrineFixturesBundle
-[functional-test-bundle]: https://github.com/liip/LiipFunctionalTestBundle
diff --git a/behat.yml b/behat.yml
index 9174366..45e5a03 100644
--- a/behat.yml
+++ b/behat.yml
@@ -5,9 +5,10 @@ default:
features: tests/Features
contexts:
- 'Acme\Features\Context\FeatureContext'
- - Knp\FriendlyContexts\Context\AliceContext
- - Knp\FriendlyContexts\Context\EntityContext
- - Knp\FriendlyContexts\Context\MinkContext
+ - 'Acme\Features\Context\DoctrineContext':
+ doctrine: '@doctrine'
+ - 'Behat\MinkExtension\Context\MinkContext'
+ - behatch:context:browser
extensions:
Behat\Symfony2Extension:
# http://zalas.eu/run-behat-scenarios-and-functional-tests-from-symfony-bundle-in-isolation-of-project/
@@ -20,16 +21,4 @@ default:
sessions:
default:
symfony2: ~
- Knp\FriendlyContexts\Extension:
- symfony_kernel:
- bootstrap: tests/App/bootstrap.php
- path: tests/App/AppKernel.php
- class: AppKernel
- env: test
- debug: true
- alice:
- fixtures:
- User: tests/Fixtures/User.yml
- Tweet: tests/Fixtures/Tweet.yml
- dependencies:
- Tweet: [ User ]
+ Behatch\Extension: ~
diff --git a/circle.yml b/circle.yml
index 36dece2..7970fcd 100644
--- a/circle.yml
+++ b/circle.yml
@@ -9,7 +9,7 @@ dependencies:
- sed -i 's/^;//' /opt/circleci/php/$(phpenv global)/etc/conf.d/xdebug.ini
- rm /opt/circleci/php/$(phpenv global)/etc/conf.d/xdebug.ini
override:
- - composer require --dev "symfony/symfony:3.4.*" --no-update
+ - composer require "symfony/symfony:3.4.*" --no-update
- composer install --no-interaction --profile --no-progress
cache_directories:
- ~/.composer/cache
diff --git a/composer.json b/composer.json
index f0bd4cc..fdbc8a6 100644
--- a/composer.json
+++ b/composer.json
@@ -14,23 +14,30 @@
"require" : {
"php": ">=7.0",
"ext-mbstring": "*",
- "symfony/symfony": "~3.4",
+ "symfony/config": "~3.4|~4.0",
+ "symfony/form": "~3.4|~4.0",
+ "symfony/framework-bundle": "~3.4|~4.0",
+ "symfony/security-csrf": "~3.4|~4.0",
+ "symfony/templating": "~3.4|~4.0",
+ "symfony/twig-bundle": "~3.4|~4.0",
+ "symfony/var-dumper": "~3.4|~4.0",
+ "doctrine/orm": "^2.4.8",
"abraham/twitteroauth": "~0.6"
},
"require-dev": {
- "doctrine/orm": "^2.4.8",
- "symfony/assetic-bundle": "~2.3",
"symfony/monolog-bundle": "~3.1",
"doctrine/doctrine-fixtures-bundle": "^3.0",
"liip/functional-test-bundle": "~2.0@alpha",
"phpunit/phpunit": "~6.5.6|~7.0",
- "knplabs/friendly-contexts": "~0.8",
"behat/behat": "~3.2",
"behat/symfony2-extension": "^2.1",
"behat/mink": "^1.7",
"behat/mink-extension": "~2.2",
"behat/mink-browserkit-driver": "~1.3",
- "phpspec/phpspec": "~3.4||~4.2"
+ "phpspec/phpspec": "~3.4||~4.2",
+ "doctrine/data-fixtures": "^1.3",
+ "nelmio/alice": "^3.4",
+ "behatch/contexts": "^3.1"
},
"autoload" : {
"psr-4" : {
diff --git a/tests/App/AppKernel.php b/tests/App/AppKernel.php
index efd1f21..5939e41 100644
--- a/tests/App/AppKernel.php
+++ b/tests/App/AppKernel.php
@@ -27,10 +27,8 @@ public function registerBundles()
{
$bundles = [
new \Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
- new \Symfony\Bundle\SecurityBundle\SecurityBundle(),
new \Symfony\Bundle\TwigBundle\TwigBundle(),
new \Symfony\Bundle\MonologBundle\MonologBundle(),
- new \Symfony\Bundle\AsseticBundle\AsseticBundle(),
new \Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
new \AlexisLefebvre\Bundle\AsyncTweetsBundle\AsyncTweetsBundle(),
new \Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle(),
diff --git a/tests/App/config.yml b/tests/App/config.yml
index 4846542..680835a 100644
--- a/tests/App/config.yml
+++ b/tests/App/config.yml
@@ -14,9 +14,6 @@ framework:
storage_id: session.storage.filesystem
profiler:
collect: false
- # Enable Assetic
- # see https://github.com/symfony/assetic-bundle/issues/396#issuecomment-160986958
- assets: ~
monolog:
handlers:
@@ -26,7 +23,7 @@ monolog:
handler: nested
nested:
type: stream
- path: %kernel.logs_dir%/%kernel.environment%.log
+ path: "%kernel.logs_dir%/%kernel.environment%.log"
level: debug
liip_functional_test:
@@ -39,7 +36,7 @@ doctrine:
connections:
default:
driver: pdo_sqlite
- path: %kernel.cache_dir%/test.db
+ path: "%kernel.cache_dir%/test.db"
orm:
auto_generate_proxy_classes: "%kernel.debug%"
auto_mapping: true
diff --git a/tests/Features/Context/DoctrineContext.php b/tests/Features/Context/DoctrineContext.php
new file mode 100644
index 0000000..a1d6237
--- /dev/null
+++ b/tests/Features/Context/DoctrineContext.php
@@ -0,0 +1,97 @@
+manager = $doctrine->getManager();
+ $this->schemaTool = new SchemaTool($this->manager);
+ $this->classes = $this->manager->getMetadataFactory()->getAllMetadata();
+ }
+
+ /**
+ * @BeforeScenario
+ */
+ public function dropData()
+ {
+ $purger = new ORMPurger();
+ $purger->setPurgeMode(ORMPurger::PURGE_MODE_DELETE);
+
+ $executor = new ORMExecutor($this->manager, $purger);
+ $executor->execute([]);
+ }
+
+ /**
+ * @AfterScenario @dropSchema
+ */
+ public function dropDatabase()
+ {
+ $this->schemaTool->dropSchema($this->classes);
+ }
+
+ /**
+ * @When I load the following fixtures:
+ */
+ public function loadFixtures(TableNode $data)
+ {
+ $this->nativeLoader = new NativeLoader();
+
+ $files = [];
+
+ foreach ($data->getRows() as $row) {
+ $name = $row[0];
+ $filePath = sprintf('%s/../../Fixtures/%s.yml', __DIR__, $name);
+
+ if (!file_exists($filePath)) {
+ throw new \RuntimeException(sprintf('File %s not found', $name));
+ }
+
+ $files[] = $filePath;
+ }
+
+ $this->objectSet = $this->nativeLoader->loadFiles($files)->getObjects();
+
+ foreach ($this->objectSet as $object) {
+ $this->manager->persist($object);
+ }
+
+ $this->manager->flush();
+ }
+}
diff --git a/tests/Features/Controller/Controller.feature b/tests/Features/Controller/Controller.feature
index 9aa3aa9..84e1ffd 100644
--- a/tests/Features/Controller/Controller.feature
+++ b/tests/Features/Controller/Controller.feature
@@ -1,8 +1,7 @@
-@reset-schema
Feature: Test DefaultController
Scenario: Index
- When I am on the homepage
+ When I am on "/"
Then I should see a "html > body" element
And I should see a "html > head > title" element
And I should see "Home timeline" in the "html > head > title" element
diff --git a/tests/Features/Controller/ControllerWithFixtures.feature b/tests/Features/Controller/ControllerWithFixtures.feature
index b0d9c9b..32b7d6f 100644
--- a/tests/Features/Controller/ControllerWithFixtures.feature
+++ b/tests/Features/Controller/ControllerWithFixtures.feature
@@ -1,9 +1,12 @@
-@reset-schema
-@alice(*)
Feature: Test DefaultController with Fixtures
+ Background:
+ Given I load the following fixtures:
+ | User |
+ | Tweet |
+
Scenario: Index
- When I am on the homepage
+ When I am on "/"
Then I should see a "html > body" element
And I should see a "html > head > title" element
And I should see "Home timeline" in the "html > head > title" element
@@ -26,10 +29,10 @@ Feature: Test DefaultController with Fixtures
And I should see "3 pending tweets" in the "body > main.container > div.navigation.row > div.count.alert.alert-info" element
# There is no message about deleted tweets
And I should not see a "div.alert.alert-success" element
- When I press the 2nd "Mark as read" link
+ When I follow the 2nd "Mark as read" link
Then I should not see a "div.alert.alert-success" element
# Delete old tweets
- When I press the "Delete old tweets" link
+ When I follow "Delete old tweets"
Then I should see a "div.alert.alert-success" element
And I should see "1 tweets deleted." in the "div.alert.alert-success" element
And I should see a "main.container > div.tweets" element
diff --git a/tests/Fixtures/Tweet.yml b/tests/Fixtures/Tweet.yml
index 0e6be33..da904a6 100644
--- a/tests/Fixtures/Tweet.yml
+++ b/tests/Fixtures/Tweet.yml
@@ -1,7 +1,7 @@
AlexisLefebvre\Bundle\AsyncTweetsBundle\Entity\Tweet:
tweet{1..3}:
id:
- created_at:
+ created_at: <(new \DateTime())>
text: "Tweet "
user: '@user'
retweet_count: 42