Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
vendor
composer.lock
36 changes: 36 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
language: php
sudo: false

jobs:
include:
- stage: Unit tests
env:
php: 7.0
- env: COMPOSER_FLAGS="--prefer-lowest"
php: 7.0
- env:
php: 7.1
- env: COMPOSER_FLAGS="--prefer-lowest"
php: 7.1
- env:
php: 7.2
- env: COMPOSER_FLAGS="--prefer-lowest"
php: 7.2
- env:
php: 7.3
- env: COMPOSER_FLAGS="--prefer-lowest"
php: 7.3

before_install:
- composer self-update

install:
- composer update -o $COMPOSER_FLAGS

script:
- ./vendor/bin/phpunit

cache:
directories:
- vendor
- $HOME/.composer/cache
13 changes: 10 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,22 @@
}
],
"require": {
"php": "^5.6 || ^7.0",
"sentry/sentry": "^1.9.2"
"php": ">=7.0",
"sentry/sentry": "^1.9.2",
"zendframework/zend-eventmanager": "^2.5|| ^3.0",
"zendframework/zend-mvc": "^2.5 || ^3.0",
"zendframework/zend-log": "^2.5 || ^3.0"
},
"require-dev": {
"phpunit/phpunit": "^5.7.27 || ^6.5.8 || ^7.1.5"
},
"conflict": {
"zendframework/zendframework": "<3.0.0"
},
"autoload": {
"psr-0": {
"ZendSentry": "src/"
"ZendSentry": "src/",
"ZendSentryTests": "tests/"
},
"classmap": [
"./Module.php"
Expand Down
26 changes: 26 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<phpunit bootstrap="./tests/bootstrap.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
verbose="true"
stopOnFailure="false"
processIsolation="false"
>
<testsuite name="Zend Sentry test suite">
<directory>./tests/ZendSentryTest</directory>
</testsuite>


<filter>
<whitelist>
<directory suffix=".php">./src</directory>
<file>./../Module.php</file>
</whitelist>
</filter>

<logging>
<log type="coverage-text" target="php://stdout"/>
<log type="coverage-clover" target="../build/logs/clover.xml"/>
</logging>
</phpunit>
45 changes: 45 additions & 0 deletions tests/ZendSentryTest/ModuleTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

namespace ZendSentryTest;

use PHPUnit\Framework\TestCase;
use Zend\Loader\StandardAutoloader;
use ZendSentry\Module as ZendSentryModule;

class ModuleTest extends TestCase
{
/**
* @var ZendSentryModule
*/
private $module;

public function setUp()
{
parent::setUp();
$this->module = new ZendSentryModule();
}

public function testDefaultModuleConfig()
{
$expectedConfig = [];

$actualConfig = $this->module->getConfig();

$this->assertEquals($expectedConfig, $actualConfig);
}

public function testAutoloaderConfig()
{
$expectedConfig = [
StandardAutoloader::class => [
'namespaces' => [
'ZendSentry' => realpath(__DIR__. '/../../src/ZendSentry')
]
]
];

$actualConfig = $this->module->getAutoloaderConfig();

$this->assertEquals($expectedConfig, $actualConfig);
}
}
18 changes: 18 additions & 0 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

chdir(__DIR__);

$loader = null;
if (file_exists('../vendor/autoload.php')) {
$loader = include '../vendor/autoload.php';
} elseif (file_exists('../../../autoload.php')) {
$loader = include '../../../autoload.php';
} else {
throw new RuntimeException('vendor/autoload.php could not be found. Did you run `php composer.phar install`?');
}

$loader->add('ZendSentryTest', __DIR__);

if (!$config = @include 'configuration.php') {
$config = require 'configuration.php.dist';
}
2 changes: 2 additions & 0 deletions tests/configuration.php.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?php
return array();