Skip to content

Commit

Permalink
Set up the bundle basics
Browse files Browse the repository at this point in the history
  • Loading branch information
indecim committed Jun 18, 2020
1 parent 6c1e4be commit 62b2097
Show file tree
Hide file tree
Showing 11 changed files with 277 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/.github export-ignore
/tests export-ignore
.gitattributes export-ignore
.gitignore export-ignore
.php_cs.dist export-ignore
phpunit.xml.dist export-ignore
84 changes: 84 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: Continuous Integration
on:
push:
branches:
- master
pull_request:

jobs:
composer-validate:
name: Validate composer.json
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/[email protected]

- name: Validate
run: composer validate --no-check-lock --strict

php-cs-fixer:
name: Lint Bundle Source
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/[email protected]

- name: Install PHP-CS-Fixer
run: composer global require friendsofphp/php-cs-fixer --prefer-dist --no-progress --no-suggest

- name: Enforce coding standards
run: $HOME/.composer/vendor/bin/php-cs-fixer fix --config $GITHUB_WORKSPACE/.php_cs.dist --diff --diff-format udiff --dry-run

tests:
name: Run tests
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
php-versions: ['7.2', '7.3', '7.4']
symfony-version: ['5.0.*', '5.1.*']

steps:
- name: Set PHP Version
run: sudo update-alternatives --set php /usr/bin/php${{ matrix.php-versions }}

- name: Disable Xdebug
run: sudo rm /etc/php/${{ matrix.php-versions }}/cli/conf.d/20-xdebug.ini

- name: Get PHP Version
run: |
ver=$(php -v | grep -oP '(?<=PHP )\d.\d')
echo "::set-output name=version::$ver"
id: php-ver

- name: Using PHP Version from matrix
run: |
echo "Runner is not using PHP Version defined in the php-versions matrix."
php -v
exit 1
if: steps.php-ver.outputs.version != matrix.php-versions

- name: Checkout
uses: actions/[email protected]

- name: Install Global Dependencies
run: |
composer global require --no-progress --no-scripts --no-plugins symfony/flex dev-master
- name: Install dependencies
run: |
composer config minimum-stability stable
composer install --prefer-dist --no-progress --no-suggest
env:
SYMFONY_REQUIRE: ${{ matrix.symfony-version }}

- name: Unit Tests
run: vendor/bin/simple-phpunit -c $GITHUB_WORKSPACE/phpunit.xml.dist --testsuite unit

- name: Functional Tests
run: vendor/bin/simple-phpunit -c $GITHUB_WORKSPACE/phpunit.xml.dist --testsuite functional

- name: Integration Tests
run: vendor/bin/simple-phpunit -c $GITHUB_WORKSPACE/phpunit.xml.dist --testsuite integration
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.*.cache
composer.lock
vendor/*
23 changes: 23 additions & 0 deletions .php_cs.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

if (!file_exists(__DIR__.'/src') || !file_exists(__DIR__.'/tests')) {
exit(0);
}

$finder = PhpCsFixer\Finder::create()
->in([__DIR__.'/src', __DIR__.'/tests'])
;

return PhpCsFixer\Config::create()
->setRules([
'@Symfony' => true,
'@Symfony:risky' => true,
'@PHPUnit75Migration:risky' => true,
'array_syntax' => ['syntax' => 'short'],
'protected_to_private' => false,
'semicolon_after_instruction' => false,
'phpdoc_to_comment' => false,
])
->setRiskyAllowed(true)
->setFinder($finder)
;
32 changes: 32 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"name": "kagonlineteam/ldap-bundle",
"description": "Symfony bundle that adds abstraction on top the default ldap component.",
"type": "symfony-bundle",
"license": "MIT",
"minimum-stability": "stable",
"require": {
"php": "^7.2",
"symfony/config": "^5.0",
"symfony/dependency-injection": "^5.0",
"symfony/http-kernel": "^5.0",
"symfony/ldap": "^5.0"
},
"require-dev": {
"symfony/framework-bundle": "^5.0",
"symfony/phpunit-bridge": "^5.0"
},
"conflict": {
"symfony/http-foundation": "<5.0",
"symfony/framework-bundle": "<5.0"
},
"autoload": {
"psr-4": {
"KAGOnlineTeam\\Bundle\\Ldap\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"KAGOnlineTeam\\Bundle\\Ldap\\Tests\\": "tests/"
}
}
}
47 changes: 47 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?>

<!-- https://phpunit.readthedocs.io/en/latest/configuration.html -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/8.3/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="vendor/autoload.php"
>
<php>
<ini name="error_reporting" value="-1" />
<server name="SHELL_VERBOSITY" value="-1" />
<server name="SYMFONY_PHPUNIT_REMOVE" value="" />
<server name="SYMFONY_PHPUNIT_VERSION" value="8.3" />
<env name="SYMFONY_DEPRECATIONS_HELPER" value="max[self]=0"/>
</php>

<testsuites>
<testsuite name="all">
<directory>./tests</directory>
</testsuite>
<testsuite name="unit">
<directory>./tests/UnitTests</directory>
</testsuite>
<testsuite name="functional">
<directory>./tests/FunctionalTests</directory>
</testsuite>
<testsuite name="integration">
<directory>./tests/IntegrationTests</directory>
</testsuite>
</testsuites>

<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./src/</directory>
<exclude>
<directory>./src/Resources</directory>
<directory>./tests</directory>
<directory>./vendor</directory>
</exclude>
</whitelist>
</filter>

<listeners>
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener" />
</listeners>
</phpunit>
24 changes: 24 additions & 0 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

namespace KAGOnlineTeam\LdapBundle\DependencyInjection;

use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;

/**
* @author Jan Flaßkamp
*/
final class Configuration implements ConfigurationInterface
{
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder('kagonlineteam_ldap');
$rootNode = $treeBuilder->getRootNode();

$rootNode
->children()
->end();

return $treeBuilder;
}
}
28 changes: 28 additions & 0 deletions src/DependencyInjection/KAGOnlineTeamLdapExtension.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace KAGOnlineTeam\LdapBundle\DependencyInjection;

use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Extension\Extension;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;

/**
* @author Jan Flaßkamp
*/
final class KAGOnlineTeamLdapExtension extends Extension
{
public function load(array $configs, ContainerBuilder $container)
{
$loader = new XmlFileLoader($container, new FileLocator(\dirname(__DIR__).'/Resources/config'));
$loader->load('ldap_services.xml');

$configuration = $this->getConfiguration($configs, $container);
$config = $this->processConfiguration($configuration, $configs);
}

public function getAlias()
{
return 'kagonlineteam_ldap';
}
}
21 changes: 21 additions & 0 deletions src/KAGOnlineTeamLdapBundle.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace KAGOnlineTeam\LdapBundle;

use KAGOnlineTeam\LdapBundle\DependencyInjection\KAGOnlineTeamLdapExtension;
use Symfony\Component\HttpKernel\Bundle\Bundle;

/**
* @author Jan Flaßkamp
*/
class KAGOnlineTeamLdapBundle extends Bundle
{
public function getContainerExtension()
{
if (null === $this->extension) {
$this->extension = new KAGOnlineTeamLdapExtension();
}

return $this->extension ?: null;
}
}
9 changes: 9 additions & 0 deletions src/Resources/config/ldap_services.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" ?>

<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">

<services>
</services>
</container>
Empty file added tests/.gitkeep
Empty file.

0 comments on commit 62b2097

Please sign in to comment.