Skip to content

Commit

Permalink
Added some tests and sf4 support (#12)
Browse files Browse the repository at this point in the history
* Added some tests and sf4 support

* Do not use -v flag

* Adding phpunit.xml

* Minors

* Make sure test pass

* Added HTTP bundle to suggest
  • Loading branch information
Nyholm authored Feb 4, 2018
1 parent 172005c commit 35094d8
Show file tree
Hide file tree
Showing 5 changed files with 151 additions and 3 deletions.
58 changes: 58 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
language: php
sudo: false
cache:
directories:
- $HOME/.composer/cache/files
- $HOME/symfony-bridge/.phpunit

env:
global:
- PHPUNIT_FLAGS="-v"
- SYMFONY_PHPUNIT_DIR="$HOME/symfony-bridge/.phpunit"

matrix:
fast_finish: true
include:
# Minimum supported dependencies with the latest and oldest PHP version
- php: 7.2
env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest" SYMFONY_DEPRECATIONS_HELPER="weak_vendors"
- php: 5.5
env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest" SYMFONY_DEPRECATIONS_HELPER="weak_vendors"

# Test the latest stable release
- php: 5.5
- php: 5.6
- php: 7.0
- php: 7.1
- php: 7.2
env: COVERAGE=true PHPUNIT_FLAGS="-v --testsuite main --coverage-text --coverage-clover=build/coverage.xml"

- php: 7.1
env: DEPENDENCIES="dunglas/symfony-lock:^2"
- php: 7.1
env: DEPENDENCIES="dunglas/symfony-lock:^3"
- php: 7.1
env: DEPENDENCIES="dunglas/symfony-lock:^4"

# Latest commit to master
- php: 7.2
env: STABILITY="dev"

allow_failures:
# Dev-master is allowed to fail.
- env: STABILITY="dev"

before_install:
- if [[ $COVERAGE != true ]]; then phpenv config-rm xdebug.ini || true; fi
- if ! [ -z "$STABILITY" ]; then composer config minimum-stability ${STABILITY}; fi;
- if ! [ -v "$DEPENDENCIES" ]; then composer require --no-update ${DEPENDENCIES}; fi;

install:
# To be removed when this issue will be resolved: https://github.com/composer/composer/issues/5355
- if [[ "$COMPOSER_FLAGS" == *"--prefer-lowest"* ]]; then composer update --prefer-dist --no-interaction --prefer-stable --quiet; fi
- composer update ${COMPOSER_FLAGS} --prefer-dist --no-interaction
- ./vendor/bin/simple-phpunit install

script:
- composer validate --strict --no-check-lock
- ./vendor/bin/simple-phpunit $PHPUNIT_FLAGS
43 changes: 43 additions & 0 deletions Tests/BundleInitializationTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

namespace Happyr\LinkedInBundle\Tests;

use Happyr\LinkedIn\LinkedIn;
use Happyr\LinkedInBundle\HappyrLinkedInBundle;
use Http\HttplugBundle\HttplugBundle;
use Nyholm\BundleTest\BaseBundleTestCase;
use Nyholm\BundleTest\CompilerPass\PublicServicePass;

class BundleInitializationTest extends BaseBundleTestCase
{
protected function setUp()
{
parent::setUp();

$this->addCompilerPass(new PublicServicePass('|happyr.*|'));
}

protected function getBundleClass()
{
return HappyrLinkedInBundle::class;
}

public function testInitBundle()
{
$kernel = $this->createKernel();
$kernel->addConfigFile(__DIR__.'/config.yml');
$kernel->addBundle(HttplugBundle::class);


// Boot the kernel.
$this->bootKernel();

// Get the container
$container = $this->getContainer();

// Test if you services exists
$this->assertTrue($container->has('happyr.linkedin'));
$service = $container->get('happyr.linkedin');
$this->assertInstanceOf(LinkedIn::class, $service);
}
}
3 changes: 3 additions & 0 deletions Tests/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
happyr_linkedin:
app_id: foo
app_secret: bar
20 changes: 17 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,28 @@
],
"require": {
"php": "^5.5 || ^7.0",
"symfony/symfony":"^2.3 || ^3.0",
"happyr/linkedin-api-client": "^1.0",
"php-http/httplug-bundle": "^1.0"
"symfony/dependency-injection": "^2.3 || ^3.0 || ^4.0",
"symfony/http-kernel": "^2.3 || ^3.0 || ^4.0"
},
"require-dev": {
"guzzlehttp/psr7": "^1.4",
"nyholm/symfony-bundle-test": "^1.3.1",
"php-http/curl-client": "^1.7",
"php-http/httplug-bundle": "^1.8",
"php-http/message": "^1.6",
"symfony/phpunit-bridge": "^3.4 || ^4.0"
},
"suggest": {
"php-http/httplug-bundle": "For easier configure your HTTP clients"
},

"autoload": {
"psr-4": {
"Happyr\\LinkedInBundle\\": ""
}
},
"config": {
"sort-packages": true
}
}

30 changes: 30 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit backupGlobals="false"
backupStaticAttributes="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
bootstrap="vendor/autoload.php"
>
<testsuites>
<testsuite name="main">
<directory>./Tests</directory>
</testsuite>
</testsuites>

<filter>
<whitelist>
<directory>.</directory>
<exclude>
<directory>./Resources</directory>
<directory>./Tests</directory>
<directory>./vendor</directory>
</exclude>
</whitelist>
</filter>
</phpunit>

0 comments on commit 35094d8

Please sign in to comment.