Skip to content
This repository has been archived by the owner on Sep 16, 2021. It is now read-only.

Commit

Permalink
support for symfony 3.4, rework test app structure
Browse files Browse the repository at this point in the history
* # This is a combination of 29 commits.
# This is the 1st commit message:

DevKit updates

# This is the commit message #2:

improvements to get the tests running

# This is the commit message #3:

try to call unit tests only

# This is the commit message #4:

DevKit updates

# This is the commit message #5:

add correct cache/log path to gitignor

# This is the commit message #6:

DevKit updates

# This is the commit message #7:

DevKit updates

# This is the commit message #8:

DevKit updates

# This is the commit message #9:

DevKit updates

# This is the commit message #10:

DevKit updates

# This is the commit message #11:

DevKit updates

# This is the commit message #12:

restriction on sebastion/exporter

# This is the commit message #13:

fix composer.json

# This is the commit message #14:

use higher versions

# This is the commit message #15:

use higher version

# This is the commit message #16:

DevKit updates

# This is the commit message #17:

DevKit updates

# This is the commit message #18:

DevKit updates

# This is the commit message #19:

try verbose

# This is the commit message #20:

try testdox

# This is the commit message #21:

try makefile change

# This is the commit message #22:

try travis

# This is the commit message #23:

back

# This is the commit message #24:

restrict sebastianbergmann/environment

# This is the commit message #25:

restrict sebastianbergmann/environment

# This is the commit message #26:

try to turn around

# This is the commit message #27:

support symfony 3.4, new testing app folder structure

# This is the commit message #28:

support symfony 3.4, new testing app folder structure

# This is the commit message #29:

use caret operator for symfony-cmf/resource-bundle

* merge conflicts

DevKit updates for master branch (#59)

* DevKit updates

* DevKit updates

* merge conflicts

fixes due to StyleCI

fix symfony component version

* re add packages after merging
  • Loading branch information
ElectricMaxxx authored Nov 16, 2017
1 parent bed0062 commit 95de338
Show file tree
Hide file tree
Showing 19 changed files with 89 additions and 78 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
tests/Resources/app/cache
tests/Resources/app/logs

tests/Fixtures/App/var
!tests/Fixtures/App/var/.gitempty
composer.lock
vendor
13 changes: 5 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,33 +26,30 @@ cache:
- $HOME/.composer/cache/files

env:
matrix: SYMFONY_VERSION=^4@dev
matrix: SYMFONY_VERSION=^3.4@dev
global:
- SYMFONY_DEPRECATIONS_HELPER=0
- SYMFONY_PHPUNIT_DIR=.phpunit SYMFONY_PHPUNIT_REMOVE="symfony/yaml"
- KERNEL_CLASS=Symfony\Cmf\Bundle\ResourceRestBundle\Tests\Fixtures\App\Kernel
- SYMFONY_PHPUNIT_VERSION=5.7
- TEST_INSTALLATION=false

matrix:
include:
- php: 7.1
env: DEPS=dev SYMFONY_VERSION=^4@dev
env: DEPS=dev SYMFONY_VERSION=^4.0@dev
- php: 7.1
env: DEPS=dev SYMFONY_VERSION=^3.4@dev
- php: 7.0
env: COMPOSER_FLAGS="--prefer-lowest" SYMFONY_VERSION=2.8.* SYMFONY_DEPRECATIONS_HELPER=weak
- php: 7.1
env: SYMFONY_VERSION=3.1.*
- php: 7.1
env: SYMFONY_VERSION=3.2.*
env: COMPOSER_FLAGS="--prefer-lowest" SYMFONY_VERSION=2.8.* SYMFONY_DEPRECATIONS_HELPER=weak
- php: 7.1
env: SYMFONY_VERSION=3.3.*
- env: TEST_INSTALLATION=true

fast_finish: true
allow_failures:
- php: 7.1
env: DEPS=dev SYMFONY_VERSION=^4@dev
env: DEPS=dev SYMFONY_VERSION=^4.0@dev
- env: TEST_INSTALLATION=true


Expand Down
5 changes: 1 addition & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,14 @@
# file that was distributed with this source code. #
############################################################################

ifeq ("symfony-cmf/resource-rest-bundle", "symfony-cmf/testing")
TESTING_SCRIPTS_DIR=bin
else
TESTING_SCRIPTS_DIR=vendor/symfony-cmf/testing/bin
endif
CONSOLE=${TESTING_SCRIPTS_DIR}/console
VERSION=dev-master
ifdef BRANCH
VERSION=dev-${BRANCH}
endif
PACKAGE=symfony-cmf/resource-rest-bundle
export KERNEL_CLASS=Symfony\Cmf\Bundle\ResourceRestBundle\Tests\Fixtures\App\Kernel
list:
@echo 'test: will run all tests'
@echo 'unit_tests: will run unit tests only'
Expand Down
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,22 @@ under the [MIT License](LICENSE).

This Bundle provides a REST API to Puli resources as provided by the CmfResource component.

#### Running Behat

1. Run web server:
```
KERNEL_CLASS="Symfony\Cmf\Bundle\ResourceRestBundle\Tests\Fixtures\App\Kernel" ./vendor/symfony-cmf/testing/bin/console server:run -d vendor/symfony-cmf/testing/resources/web/ 8000
```
2. Run the behat tests:
```
KERNEL_CLASS="Symfony\Cmf\Bundle\ResourceRestBundle\Tests\Fixtures\App\Kernel" ./vendor/bin/behat
```


## Requirements

* PHP 7.0 / 7.1
* Symfony 2.8 / 3.1 / 3.2 / 3.3 / ^3.4@dev
* PHP 7.1
* Symfony 2.8 / 3.3 / ^3.4@dev
* See also the `require` section of [composer.json](composer.json)

## Documentation
Expand Down
17 changes: 13 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,28 @@
"php": "^5.6|^7.0",
"symfony-cmf/resource-bundle": "^1.0",
"jms/serializer-bundle": "^1.0 | ^2.0",
"symfony/translation": "^2.8|^3.0",
"symfony/symfony": "2.8.*"
"symfony/translation": "^2.8|^3.0"
},
"require-dev": {
"symfony-cmf/testing": "^2.1@dev",
"symfony/phpunit-bridge": "^3.3.10",
"doctrine/phpcr-odm": "^1.3",
"doctrine/phpcr-odm": "^1.4|^2.0",
"jms/serializer": "^1.2",
"behat/behat": "^3.0.6",
"behat/web-api-extension" : "^1.0@dev",
"matthiasnoback/symfony-dependency-injection-test": "^1.1",
"matthiasnoback/symfony-config-test": "^2.1"
"matthiasnoback/symfony-config-test": "^2.1",
"symfony/twig-bundle": "^2.8|^3.3",
"symfony/validator": "^2.8|^3.3",
"symfony/security-bundle": "^2.8|^3.3",
"symfony/asset": "^2.8|^3.3",
"symfony/templating": "^2.8|^3.3",
"symfony/form": "^2.8|^3.3",
"symfony/web-server-bundle": "^2.8|^3.3",
"symfony/translation": "^2.8|^3.3"
},
"minimum-stability":"dev",

"prefer-stable": true,
"suggest": {
"doctrine/phpcr-odm": "To enable support for the PHPCR ODM documents (^1.2)",
Expand Down
5 changes: 0 additions & 5 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,4 @@
</exclude>
</whitelist>
</filter>

<php>
<server name="KERNEL_DIR" value="tests/Resources/app" />
</php>

</phpunit>
19 changes: 12 additions & 7 deletions tests/Features/Context/ResourceContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Behat\Gherkin\Node\TableNode;
use PHPCR\Util\NodeHelper;
use PHPCR\Util\PathHelper;
use Symfony\Cmf\Bundle\ResourceRestBundle\Tests\Fixtures\App\Kernel;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Finder\Finder;
use Symfony\Component\HttpKernel\KernelInterface;
Expand All @@ -35,9 +36,9 @@ class ResourceContext implements Context
public function __construct()
{
require_once __DIR__.'/../../../vendor/symfony-cmf/testing/bootstrap/bootstrap.php';
require_once __DIR__.'/../../Resources/app/AppKernel.php';
require_once __DIR__.'/../../Fixtures/App/Kernel.php';

$this->kernel = new \AppKernel('test', true);
$this->kernel = new Kernel('test', true);
}

/**
Expand All @@ -49,7 +50,7 @@ public function __construct()
*/
public static function getConfigurationFile()
{
return __DIR__.'/../../Resources/app/cache/resource.yml';
return __DIR__.'/../../Fixtures/App/var/cache/resource.yml';
}

/**
Expand Down Expand Up @@ -108,7 +109,7 @@ public function createFile($filename, PyStringNode $content)
*/
public function createDocument($class, $path, TableNode $fields)
{
$class = 'Symfony\\Cmf\\Bundle\\ResourceRestBundle\\Tests\\Resources\\TestBundle\\Document\\'.$class;
$class = 'Symfony\\Cmf\\Bundle\\ResourceRestBundle\\Tests\\Fixtures\\App\\Document\\'.$class;
$path = '/tests'.$path;

$parentPath = PathHelper::getParentPath($path);
Expand Down Expand Up @@ -142,7 +143,7 @@ public function createDocument($class, $path, TableNode $fields)
*/
public function thereIsADocumentAt($class, $path, TableNode $fields = null)
{
$class = 'Symfony\\Cmf\\Bundle\\ResourceRestBundle\\Tests\\Resources\\TestBundle\\Document\\'.$class;
$class = 'Symfony\\Cmf\\Bundle\\ResourceRestBundle\\Tests\\Fixtures\\App\\Document\\'.$class;
$path = '/tests'.$path;

if (!class_exists($class)) {
Expand Down Expand Up @@ -170,7 +171,7 @@ public function thereIsADocumentAt($class, $path, TableNode $fields = null)
*/
public function thereIsNoDocumentAt($class, $path)
{
$class = 'Symfony\\Cmf\\Bundle\\ResourceRestBundle\\Tests\\Resources\\TestBundle\\Document\\'.$class;
$class = 'Symfony\\Cmf\\Bundle\\ResourceRestBundle\\Tests\\Fixtures\\App\\Document\\'.$class;
$path = '/tests'.$path;

if (!class_exists($class)) {
Expand All @@ -191,7 +192,11 @@ public function thereIsNoDocumentAt($class, $path)
private function clearDiCache()
{
$finder = new Finder();
$finder->in($this->kernel->getCacheDir());
$dirs = $this->kernel->getCacheDir();
if (!is_dir($dirs)) {
return;
}
$finder->in($dirs);
$finder->name('*.php');
$finder->name('*.php.meta');
$filesystem = new Filesystem();
Expand Down
6 changes: 3 additions & 3 deletions tests/Features/nesting.feature
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Feature: Nesting resources
"repository_alias": "default",
"repository_type": "doctrine/phpcr-odm",
"payload_alias": null,
"payload_type": "Symfony\\Cmf\\Bundle\\ResourceRestBundle\\Tests\\Resources\\TestBundle\\Document\\Article",
"payload_type": "Symfony\\Cmf\\Bundle\\ResourceRestBundle\\Tests\\Fixtures\\App\\Document\\Article",
"path": "\/foo",
"node_name": "foo",
"label": "foo",
Expand All @@ -42,7 +42,7 @@ Feature: Nesting resources
"repository_alias": "default",
"repository_type": "doctrine/phpcr-odm",
"payload_alias": null,
"payload_type": "Symfony\\Cmf\\Bundle\\ResourceRestBundle\\Tests\\Resources\\TestBundle\\Document\\Article",
"payload_type": "Symfony\\Cmf\\Bundle\\ResourceRestBundle\\Tests\\Fixtures\\App\\Document\\Article",
"path": "\/foo\/sub",
"node_name": "sub",
"label": "sub",
Expand All @@ -63,7 +63,7 @@ Feature: Nesting resources
"repository_alias": "default",
"repository_type": "doctrine/phpcr-odm",
"payload_alias": null,
"payload_type": "Symfony\\Cmf\\Bundle\\ResourceRestBundle\\Tests\\Resources\\TestBundle\\Document\\Article",
"payload_type": "Symfony\\Cmf\\Bundle\\ResourceRestBundle\\Tests\\Fixtures\\App\\Document\\Article",
"path": "\/foo",
"node_name": "foo",
"label": "foo",
Expand Down
12 changes: 6 additions & 6 deletions tests/Features/resource_api_phpcr_odm.feature
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Feature: PHPCR-ODM resource repository
payload_alias_map:
article:
repository: doctrine/phpcr-odm
type: "Symfony\\Cmf\\Bundle\\ResourceRestBundle\\Tests\\Resources\\TestBundle\\Document\\Article"
type: "Symfony\\Cmf\\Bundle\\ResourceRestBundle\\Tests\\Fixtures\\App\\Document\\Article"
security:
access_control:
- { pattern: '^/', require: IS_AUTHENTICATED_ANONYMOUSLY }
Expand All @@ -36,7 +36,7 @@ Feature: PHPCR-ODM resource repository
"repository_alias": "phpcrodm_repo",
"repository_type": "doctrine/phpcr-odm",
"payload_alias": "article",
"payload_type": "Symfony\\Cmf\\Bundle\\ResourceRestBundle\\Tests\\Resources\\TestBundle\\Document\\Article",
"payload_type": "Symfony\\Cmf\\Bundle\\ResourceRestBundle\\Tests\\Fixtures\\App\\Document\\Article",
"path": "\/foo",
"node_name": "foo",
"label": "foo",
Expand Down Expand Up @@ -66,7 +66,7 @@ Feature: PHPCR-ODM resource repository
"repository_alias": "phpcrodm_repo",
"repository_type": "doctrine/phpcr-odm",
"payload_alias": "article",
"payload_type": "Symfony\\Cmf\\Bundle\\ResourceRestBundle\\Tests\\Resources\\TestBundle\\Document\\Article",
"payload_type": "Symfony\\Cmf\\Bundle\\ResourceRestBundle\\Tests\\Fixtures\\App\\Document\\Article",
"path": "\/foo",
"node_name": "foo",
"label": "foo",
Expand All @@ -76,7 +76,7 @@ Feature: PHPCR-ODM resource repository
"repository_alias": "phpcrodm_repo",
"repository_type": "doctrine/phpcr-odm",
"payload_alias": "article",
"payload_type": "Symfony\\Cmf\\Bundle\\ResourceRestBundle\\Tests\\Resources\\TestBundle\\Document\\Article",
"payload_type": "Symfony\\Cmf\\Bundle\\ResourceRestBundle\\Tests\\Fixtures\\App\\Document\\Article",
"path": "/foo/bar",
"node_name": "bar",
"label": "bar",
Expand All @@ -88,7 +88,7 @@ Feature: PHPCR-ODM resource repository
"repository_alias": "phpcrodm_repo",
"repository_type": "doctrine/phpcr-odm",
"payload_alias": "article",
"payload_type": "Symfony\\Cmf\\Bundle\\ResourceRestBundle\\Tests\\Resources\\TestBundle\\Document\\Article",
"payload_type": "Symfony\\Cmf\\Bundle\\ResourceRestBundle\\Tests\\Fixtures\\App\\Document\\Article",
"path": "/foo/boo",
"node_name": "boo",
"label": "boo",
Expand Down Expand Up @@ -134,7 +134,7 @@ Feature: PHPCR-ODM resource repository
"repository_alias": "phpcrodm_repo",
"repository_type": "doctrine/phpcr-odm",
"payload_alias": "article",
"payload_type": "Symfony\\Cmf\\Bundle\\ResourceRestBundle\\Tests\\Resources\\TestBundle\\Document\\Article",
"payload_type": "Symfony\\Cmf\\Bundle\\ResourceRestBundle\\Tests\\Fixtures\\App\\Document\\Article",
"path": "\/bar\/foo",
"node_name": "foo",
"label": "foo",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace Symfony\Cmf\Bundle\ResourceRestBundle\Tests\Resources\TestBundle\Description;
namespace Symfony\Cmf\Bundle\ResourceRestBundle\Tests\Fixtures\App\Description;

use Symfony\Cmf\Component\Resource\Description\Description;
use Symfony\Cmf\Component\Resource\Description\DescriptionEnhancerInterface;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace Symfony\Cmf\Bundle\ResourceRestBundle\Tests\Resources\TestBundle\Document;
namespace Symfony\Cmf\Bundle\ResourceRestBundle\Tests\Fixtures\App\Document;

use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCR;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,41 +9,31 @@
* file that was distributed with this source code.
*/

namespace Symfony\Cmf\Bundle\ResourceRestBundle\Tests\Fixtures\App;

use Symfony\Cmf\Bundle\ResourceRestBundle\Tests\Features\Context\ResourceContext;
use Symfony\Cmf\Component\Testing\HttpKernel\TestKernel;
use Symfony\Component\Config\Loader\LoaderInterface;

/**
* This is the kernel used by the application being tested.
*/
class AppKernel extends TestKernel
class Kernel extends TestKernel
{
private $configPath;

public function setConfig($configPath)
{
$this->config = $configPath;
}

public function configure()
{
$this->requireBundleSets([
'default', 'phpcr_odm',
]);

$this->addBundles([
new \Symfony\Cmf\Bundle\ResourceRestBundle\Tests\Resources\TestBundle\TestBundle(),
new \Symfony\Cmf\Bundle\ResourceRestBundle\CmfResourceRestBundle(),
new \Symfony\Cmf\Bundle\ResourceBundle\CmfResourceBundle(),
new \JMS\SerializerBundle\JMSSerializerBundle(),
]);
$this->registerConfiguredBundles();
}

public function registerContainerConfiguration(LoaderInterface $loader)
{
$loader->load(__DIR__.'/config/config.php');

if ($this->getEnvironment() !== 'behat' && file_exists(ResourceContext::getConfigurationFile())) {
if ('behat' !== $this->getEnvironment() && file_exists(ResourceContext::getConfigurationFile())) {
$loader->import(ResourceContext::getConfigurationFile());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace Symfony\Cmf\Bundle\ResourceRestBundle\Tests\Resources\TestBundle\Security;
namespace Symfony\Cmf\Bundle\ResourceRestBundle\Tests\Fixtures\App\Security;

use Symfony\Cmf\Bundle\ResourceRestBundle\Controller\ResourceController;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
Expand Down
24 changes: 24 additions & 0 deletions tests/Fixtures/App/config/bundles.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

/*
* This file is part of the Symfony CMF package.
*
* (c) 2011-2017 Symfony CMF
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

use JMS\SerializerBundle\JMSSerializerBundle;
use Symfony\Bundle\TwigBundle\TwigBundle;
use Symfony\Bundle\WebServerBundle\WebServerBundle;
use Symfony\Cmf\Bundle\ResourceBundle\CmfResourceBundle;
use Symfony\Cmf\Bundle\ResourceRestBundle\CmfResourceRestBundle;

return [
CmfResourceRestBundle::class => ['all' => true],
CmfResourceBundle::class => ['all' => true],
JMSSerializerBundle::class => ['all' => true],
TwigBundle::class => ['all' => true],
WebServerBundle::class => ['all' => true],
];
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

use Symfony\Cmf\Bundle\ResourceRestBundle\Tests\Resources\TestBundle\Description\DummyEnhancer;
use Symfony\Cmf\Bundle\ResourceRestBundle\Tests\Fixtures\App\Description\DummyEnhancer;

$container->setParameter('cmf_testing.bundle_fqn', 'Symfony\Cmf\Bundle\ResourceRestBundle');
$loader->import(CMF_TEST_CONFIG_DIR.'/dist/parameters.yml');
Expand Down
Empty file.
Loading

0 comments on commit 95de338

Please sign in to comment.