Merge
This commit is contained in:
2
.gitattributes
vendored
2
.gitattributes
vendored
@ -4,5 +4,5 @@
|
|||||||
/.gitattributes export-ignore
|
/.gitattributes export-ignore
|
||||||
/.gitignore export-ignore
|
/.gitignore export-ignore
|
||||||
/.travis.yml export-ignore
|
/.travis.yml export-ignore
|
||||||
/phpunit.xml export-ignore
|
/phpunit.xml.dist export-ignore
|
||||||
/README.md export-ignore
|
/README.md export-ignore
|
||||||
|
5
.gitignore
vendored
5
.gitignore
vendored
@ -1,6 +1,3 @@
|
|||||||
/vendor
|
|
||||||
composer.phar
|
|
||||||
composer.lock
|
composer.lock
|
||||||
.DS_Store
|
|
||||||
.idea
|
|
||||||
phpunit.xml
|
phpunit.xml
|
||||||
|
vendor
|
||||||
|
17
.travis.yml
17
.travis.yml
@ -1,12 +1,21 @@
|
|||||||
language: php
|
language: php
|
||||||
|
|
||||||
php:
|
php:
|
||||||
|
- 5.5.9
|
||||||
- 5.5
|
- 5.5
|
||||||
- 5.6
|
- 5.6
|
||||||
|
- 7.0
|
||||||
- hhvm
|
- hhvm
|
||||||
|
|
||||||
before_script:
|
sudo: false
|
||||||
- composer self-update
|
|
||||||
- composer install --prefer-source --no-interaction --dev
|
|
||||||
|
|
||||||
script: vendor/bin/phpspec run
|
install:
|
||||||
|
- travis_retry composer install --no-interaction --prefer-source
|
||||||
|
|
||||||
|
script:
|
||||||
|
- if [ "$TRAVIS_PHP_VERSION" != "5.5.9" ] && [ "$TRAVIS_PHP_VERSION" != "5.5" ] && [ "$TRAVIS_PHP_VERSION" != "5.6" ]; then vendor/bin/phpunit; fi
|
||||||
|
- if [ "$TRAVIS_PHP_VERSION" == "5.5.9" ] || [ "$TRAVIS_PHP_VERSION" == "5.5" ] || [ "$TRAVIS_PHP_VERSION" == "5.6" ]; then vendor/bin/phpunit --coverage-clover build/logs/clover.xml; fi
|
||||||
|
|
||||||
|
after_script:
|
||||||
|
- if [ "$TRAVIS_PHP_VERSION" == "5.5.9" ] || [ "$TRAVIS_PHP_VERSION" == "5.5" ] || [ "$TRAVIS_PHP_VERSION" == "5.6" ]; then wget https://scrutinizer-ci.com/ocular.phar; fi
|
||||||
|
- if [ "$TRAVIS_PHP_VERSION" == "5.5.9" ] || [ "$TRAVIS_PHP_VERSION" == "5.5" ] || [ "$TRAVIS_PHP_VERSION" == "5.6" ]; then php ocular.phar code-coverage:upload --format=php-clover build/logs/clover.xml; fi
|
||||||
|
2
LICENSE
2
LICENSE
@ -1,6 +1,6 @@
|
|||||||
The MIT License (MIT)
|
The MIT License (MIT)
|
||||||
|
|
||||||
Copyright (c) 2014 Tom Lingham
|
Copyright (c) 2014-2016 Tom Lingham <tjlingham@gmail.com>
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -10,17 +10,24 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=5.5.0",
|
"php": "^5.5.9 || ^7.0",
|
||||||
"illuminate/support": "5.*"
|
"illuminate/support": "5.1.* || 5.2.*"
|
||||||
},
|
},
|
||||||
"require-dev" :{
|
"require-dev" :{
|
||||||
"phpspec/phpspec": "~2.0"
|
"graham-campbell/testbench": "^3.1",
|
||||||
|
"mockery/mockery": "^0.9.4",
|
||||||
|
"phpunit/phpunit": "^4.8 || ^5.0"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
"TomLingham\\Searchy\\": "src/"
|
"TomLingham\\Searchy\\": "src/"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"autoload-dev": {
|
||||||
|
"psr-4": {
|
||||||
|
"TomLingham\\Tests\\Searchy\\": "tests/"
|
||||||
|
}
|
||||||
|
},
|
||||||
"config": {
|
"config": {
|
||||||
"preferred-install": "dist"
|
"preferred-install": "dist"
|
||||||
},
|
},
|
||||||
|
@ -1,18 +1,28 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<phpunit backupGlobals="false"
|
<phpunit backupGlobals="false"
|
||||||
backupStaticAttributes="false"
|
backupStaticAttributes="false"
|
||||||
|
beStrictAboutTestsThatDoNotTestAnything="true"
|
||||||
|
beStrictAboutOutputDuringTests="true"
|
||||||
bootstrap="vendor/autoload.php"
|
bootstrap="vendor/autoload.php"
|
||||||
colors="true"
|
colors="true"
|
||||||
convertErrorsToExceptions="true"
|
convertErrorsToExceptions="true"
|
||||||
convertNoticesToExceptions="true"
|
convertNoticesToExceptions="true"
|
||||||
convertWarningsToExceptions="true"
|
convertWarningsToExceptions="true"
|
||||||
|
failOnRisky="true"
|
||||||
|
failOnWarning="true"
|
||||||
processIsolation="false"
|
processIsolation="false"
|
||||||
|
stopOnError="false"
|
||||||
stopOnFailure="false"
|
stopOnFailure="false"
|
||||||
syntaxCheck="false"
|
verbose="true"
|
||||||
>
|
>
|
||||||
<testsuites>
|
<testsuites>
|
||||||
<testsuite name="Laravel Searchy Test Suite">
|
<testsuite name="Laravel Searchy Test Suite">
|
||||||
<directory suffix=".php">./tests/</directory>
|
<directory suffix="Test.php">./tests</directory>
|
||||||
</testsuite>
|
</testsuite>
|
||||||
</testsuites>
|
</testsuites>
|
||||||
|
<filter>
|
||||||
|
<whitelist processUncoveredFilesFromWhitelist="true">
|
||||||
|
<directory suffix=".php">./src</directory>
|
||||||
|
</whitelist>
|
||||||
|
</filter>
|
||||||
</phpunit>
|
</phpunit>
|
||||||
|
@ -2,67 +2,82 @@
|
|||||||
|
|
||||||
namespace TomLingham\Searchy;
|
namespace TomLingham\Searchy;
|
||||||
|
|
||||||
|
use Illuminate\Contracts\Container\Container;
|
||||||
|
use Illuminate\Foundation\Application as LaravelApplication;
|
||||||
use Illuminate\Support\ServiceProvider;
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
use Laravel\Lumen\Application as LumenApplication;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is the searchy service provider class.
|
||||||
|
*
|
||||||
|
* @author Tom Lingham <tjlingham@gmail.com>
|
||||||
|
* @author Vincent Klaiber <hello@vinkla.com>
|
||||||
|
*/
|
||||||
class SearchyServiceProvider extends ServiceProvider
|
class SearchyServiceProvider extends ServiceProvider
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Indicates if loading of the provider is deferred.
|
* Boot the service provider.
|
||||||
*
|
*
|
||||||
* @var bool
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected $defer = false;
|
public function boot()
|
||||||
|
|
||||||
/**
|
|
||||||
* Register the service provider.
|
|
||||||
*/
|
|
||||||
public function register()
|
|
||||||
{
|
{
|
||||||
//
|
$this->setupConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers searchy.
|
* Setup the config.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function registerSearchy()
|
protected function setupConfig()
|
||||||
{
|
|
||||||
// Laravel <= 5.1
|
|
||||||
$closure = function ($app) {
|
|
||||||
return new SearchBuilder( $app['config'] );
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
if ( method_exists($this->app, 'bindShared') )
|
|
||||||
{
|
|
||||||
$this->app->bindShared('searchy', $closure);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Laravel 5.2 Goodness :)
|
|
||||||
else {
|
|
||||||
$this->app->singleton('searchy', $closure);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Loads the configuration file.
|
|
||||||
*/
|
|
||||||
public function setupConfig()
|
|
||||||
{
|
{
|
||||||
$source = realpath(__DIR__.'/../config/searchy.php');
|
$source = realpath(__DIR__.'/../config/searchy.php');
|
||||||
|
|
||||||
if (class_exists('Illuminate\Foundation\Application', false)) {
|
if ($this->app instanceof LaravelApplication && $this->app->runningInConsole()) {
|
||||||
$this->publishes([$source => config_path('searchy.php')]);
|
$this->publishes([$source => config_path('searchy.php')]);
|
||||||
|
} elseif ($this->app instanceof LumenApplication) {
|
||||||
|
$this->app->configure('searchy');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->mergeConfigFrom($source, 'searchy');
|
$this->mergeConfigFrom($source, 'searchy');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Boot the service provider.
|
* Register the service provider.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function boot()
|
public function register()
|
||||||
{
|
{
|
||||||
$this->setupConfig();
|
$this->registerSearchBuilder();
|
||||||
$this->registerSearchy();
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register the search builder class.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function registerSearchBuilder()
|
||||||
|
{
|
||||||
|
$this->app->singleton('searchy', function (Container $app) {
|
||||||
|
$config = $app['config'];
|
||||||
|
|
||||||
|
return new SearchBuilder($config);
|
||||||
|
});
|
||||||
|
|
||||||
|
$this->app->alias('searchy', HashidsFactory::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the services provided by the provider.
|
||||||
|
*
|
||||||
|
* @return string[]
|
||||||
|
*/
|
||||||
|
public function provides()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'searchy',
|
||||||
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
26
tests/AbstractTestCase.php
Normal file
26
tests/AbstractTestCase.php
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace TomLingham\Tests\Searchy;
|
||||||
|
|
||||||
|
use GrahamCampbell\TestBench\AbstractPackageTestCase;
|
||||||
|
use TomLingham\Searchy\SearchyServiceProvider;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is the abstract test case class.
|
||||||
|
*
|
||||||
|
* @author Vincent Klaiber <hello@vinkla.com>
|
||||||
|
*/
|
||||||
|
abstract class AbstractTestCase extends AbstractPackageTestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Get the service provider class.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Contracts\Foundation\Application $app
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected function getServiceProviderClass($app)
|
||||||
|
{
|
||||||
|
return SearchyServiceProvider::class;
|
||||||
|
}
|
||||||
|
}
|
48
tests/Facades/SearchyTest.php
Normal file
48
tests/Facades/SearchyTest.php
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace TomLingham\Tests\Searchy\Facades;
|
||||||
|
|
||||||
|
use GrahamCampbell\TestBenchCore\FacadeTrait;
|
||||||
|
use TomLingham\Searchy\Facades\Searchy;
|
||||||
|
use TomLingham\Searchy\SearchBuilder;
|
||||||
|
use TomLingham\Tests\Searchy\AbstractTestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is the searchy facade test class.
|
||||||
|
*
|
||||||
|
* @author Vincent Klaiber <hello@vinkla.com>
|
||||||
|
*/
|
||||||
|
class SearchyTest extends AbstractTestCase
|
||||||
|
{
|
||||||
|
use FacadeTrait;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the facade accessor.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected function getFacadeAccessor()
|
||||||
|
{
|
||||||
|
return 'searchy';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the facade class.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected function getFacadeClass()
|
||||||
|
{
|
||||||
|
return Searchy::class;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the facade root.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected function getFacadeRoot()
|
||||||
|
{
|
||||||
|
return SearchBuilder::class;
|
||||||
|
}
|
||||||
|
}
|
21
tests/ServiceProviderTest.php
Normal file
21
tests/ServiceProviderTest.php
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace TomLingham\Tests\Searchy;
|
||||||
|
|
||||||
|
use GrahamCampbell\TestBenchCore\ServiceProviderTrait;
|
||||||
|
use TomLingham\Searchy\SearchBuilder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is the service provider test.
|
||||||
|
*
|
||||||
|
* @author Vincent Klaiber <hello@vinkla.com>
|
||||||
|
*/
|
||||||
|
class ServiceProviderTest extends AbstractTestCase
|
||||||
|
{
|
||||||
|
use ServiceProviderTrait;
|
||||||
|
|
||||||
|
public function testSearchBuilderIsInjectable()
|
||||||
|
{
|
||||||
|
$this->assertIsInjectable(SearchBuilder::class);
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user