Skip to content

Commit c0dafe0

Browse files
committed
Stubbing out the project
0 parents  commit c0dafe0

13 files changed

+472
-0
lines changed

.editorconfig

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
insert_final_newline = true
7+
indent_style = space
8+
indent_size = 4
9+
trim_trailing_whitespace = true
10+
11+
[*.md]
12+
trim_trailing_whitespace = false
13+
14+
[*.yml]
15+
indent_style = space
16+
indent_size = 2

.gitattributes

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
* text=auto
2+
3+
/build export-ignore
4+
/tests export-ignore
5+
.gitattributes export-ignore
6+
.gitignore export-ignore
7+
.travis.yml export-ignore
8+
gulpfile.js
9+
nitpick.json export-ignore
10+
phpunit.xml.dist export-ignore

.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/vendor
2+
/node_modules
3+
phpunit.xml
4+
/build
5+
composer.lock

.travis.yml

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
language: php
2+
3+
php:
4+
- 5.5.9
5+
- 5.5
6+
- 5.6
7+
- 7.0
8+
- 7.1
9+
10+
env:
11+
global:
12+
- setup=basic
13+
14+
matrix:
15+
include:
16+
- php: 7.0
17+
env: setup=lowest
18+
- php: 7.0
19+
env: setup=stable
20+
- php: 7.1
21+
env: setup=lowest
22+
- php: 7.1
23+
env: setup=stable
24+
25+
sudo: false
26+
27+
cache:
28+
directories:
29+
- $HOME/.composer/cache
30+
31+
before_install:
32+
- phpenv config-rm xdebug.ini
33+
- echo "extension = memcached.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
34+
- travis_retry composer self-update
35+
36+
install:
37+
- if [[ $setup = 'basic' ]]; then travis_retry composer install --no-interaction --prefer-source; fi
38+
- if [[ $setup = 'stable' ]]; then travis_retry composer update --prefer-source --no-interaction --prefer-stable; fi
39+
- if [[ $setup = 'lowest' ]]; then travis_retry composer update --prefer-source --no-interaction --prefer-lowest --prefer-stable; fi
40+
41+
before_script: mkdir -p build/logs
42+
43+
script: vendor/bin/phpunit
44+
45+
after_script: vendor/bin/coveralls -v -n

VERSION

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.0.0

composer.json

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
{
2+
"name": "spinen/laravel-discourse-sso",
3+
"description": "Integrate Discourse SSO into Laravel.",
4+
"keywords": [
5+
"discourse",
6+
"laravel",
7+
"library",
8+
"single sign on",
9+
"spinen",
10+
"sso"
11+
],
12+
"license": "MIT",
13+
"authors": [
14+
{
15+
"name": "Jimmy Puckett",
16+
"email": "[email protected]"
17+
}
18+
],
19+
"require": {
20+
"php": ">=5.5.9",
21+
"cviebrock/discourse-php": "^0.9.3",
22+
"illuminate/support": "~5.1.10|5.2.*|5.3.*|5.4.*"
23+
},
24+
"require-dev": {
25+
"mockery/mockery": "^0.9.1",
26+
"phpunit/phpunit": "~4.0|~5.0",
27+
"psy/psysh": "^0.5.1",
28+
"satooshi/php-coveralls": "^0.6.1|^1",
29+
"symfony/var-dumper": "~2.7|~3.0"
30+
},
31+
"autoload": {
32+
"psr-4": {
33+
"Spinen\\Discourse\\": "src"
34+
}
35+
},
36+
"autoload-dev": {
37+
"psr-4": {
38+
"Spinen\\Discourse\\": "tests"
39+
}
40+
},
41+
"extra": {
42+
"laravel": {
43+
"providers": [
44+
"Spinen\\Discourse\\SsoServiceProvider"
45+
],
46+
}
47+
},
48+
"config": {
49+
"sort-packages": true
50+
},
51+
"minimum-stability": "dev",
52+
"prefer-stable": true
53+
}

gulpfile.js

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
var gulp = require('gulp');
2+
var phpunit = require('gulp-phpunit');
3+
var notify = require('gulp-notify')
4+
5+
var paths = {
6+
tests: ['tests/**/*Test.php'],
7+
};
8+
9+
// Lint the shell code
10+
gulp.task('phpunit', function () {
11+
return gulp.src(paths.tests, {read: false})
12+
.pipe(phpunit())
13+
.pipe(notify(function (file) {
14+
// TODO: Give alert of pass/fail
15+
return file.path
16+
}))
17+
})
18+
19+
// Rerun the task when a file changes
20+
gulp.task('watch', function() {
21+
gulp.watch(paths.tests, ['phpunit']);
22+
});
23+
24+
// The default task (called when you run `gulp` from cli)
25+
gulp.task('default', ['phpunit']);

nitpick.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"ignore": [
3+
"tests/*"
4+
]
5+
}

phpunit.xml.dist

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<!--
4+
This is the "dist(ribution)" phpunit.xml.dist file. It sets the defaults that are then over written by any files in
5+
phpunit.xml, which is then over wrote by flags passed in via the command line. The plan is that this file is to be
6+
used by ci to do the full suit of tests, and a developer can copy this file to phpunit.xml to trim down some of the
7+
options.
8+
-->
9+
10+
<phpunit addUncoveredFilesFromWhitelist="true"
11+
backupGlobals="false"
12+
backupStaticAttributes="false"
13+
bootstrap="vendor/autoload.php"
14+
colors="true"
15+
convertErrorsToExceptions="true"
16+
convertNoticesToExceptions="true"
17+
convertWarningsToExceptions="true"
18+
processIsolation="false"
19+
processUncoveredFilesFromWhitelist="true"
20+
stopOnFailure="false"
21+
syntaxCheck="false"
22+
verbose="true">
23+
24+
<testsuites>
25+
<testsuite name="Laravel Discourse SSO Test Suite">
26+
<directory>./tests/</directory>
27+
</testsuite>
28+
</testsuites>
29+
30+
<php>
31+
<!-- <env name="VARIABLE" value="value"/> -->
32+
</php>
33+
34+
<filter>
35+
<whitelist>
36+
<directory suffix=".php">src/</directory>
37+
<exclude>
38+
<!--<file>src/file.php</file>-->
39+
<directory suffix=".php">src/config</directory>
40+
</exclude>
41+
</whitelist>
42+
</filter>
43+
44+
<logging>
45+
<log type="coverage-html"
46+
target="./build/coverage"
47+
title="Laravel Discourse SSO Test Suite"
48+
charset="UTF-8"
49+
yui="true"
50+
highlight="true"
51+
lowUpperBound="35"
52+
highLowerBound="70"/>
53+
<log type="coverage-clover" target="build/logs/clover.xml"/>
54+
<log type="json" target="./build/logs/logfile.json"/>
55+
<log type="junit" target="./build/logs/junit.xml"
56+
logIncompleteSkipped="true"/>
57+
</logging>
58+
</phpunit>

readme.md

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# SPINEN's Discourse SSO for Laravel
2+
3+
[![Latest Stable Version](https://poser.pugx.org/spinen/laravel-discourse-sso/v/stable)](https://packagist.org/packages/spinen/laravel-discourse-sso)
4+
[![Total Downloads](https://poser.pugx.org/spinen/laravel-discourse-sso/downloads)](https://packagist.org/packages/spinen/laravel-discourse-sso)
5+
[![Latest Unstable Version](https://poser.pugx.org/spinen/laravel-discourse-sso/v/unstable)](https://packagist.org/packages/spinen/laravel-discourse-sso)
6+
[![Dependency Status](https://www.versioneye.com/php/spinen:laravel-discourse-sso/0.1.1/badge.svg)](https://www.versioneye.com/php/spinen:laravel-discourse-sso/0.1.1)
7+
[![License](https://poser.pugx.org/spinen/laravel-discourse-sso/license)](https://packagist.org/packages/spinen/laravel-discourse-sso)
8+
9+
[Discourse](https://www.discourse.org) is a great online forum software that supports Single Sign On ([SSO](https://meta.discourse.org/t/official-single-sign-on-for-discourse/13045)). There is a great PHP library that handles all of the heavy lifting to make the SSO work called [cviebrock/discourse-php](https://github.com/cviebrock/discourse-php), which this package uses. This package is loosely based on the work done by [jaewun/discourse-sso-laravel](https://github.com/jaewun/discourse-sso-laravel).
10+
11+
## Build Status
12+
13+
| Branch | Status | Coverage | Code Quality |
14+
| ------ | :----: | :------: | :----------: |
15+
| Develop | [![Build Status](https://travis-ci.org/spinen/laravel-discourse-sso.svg?branch=develop)](https://travis-ci.org/spinen/laravel-discourse-sso) | [![Coverage Status](https://coveralls.io/repos/spinen/laravel-discourse-sso/badge.svg?branch=develop&service=github)](https://coveralls.io/github/spinen/laravel-discourse-sso?branch=develop) | [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/spinen/laravel-discourse-sso/badges/quality-score.png?b=develop)](https://scrutinizer-ci.com/g/spinen/laravel-discourse-sso/?branch=develop) |
16+
| Master | [![Build Status](https://travis-ci.org/spinen/laravel-discourse-sso.svg?branch=master)](https://travis-ci.org/spinen/laravel-discourse-sso) | [![Coverage Status](https://coveralls.io/repos/spinen/laravel-discourse-sso/badge.svg?branch=master&service=github)](https://coveralls.io/github/spinen/laravel-discourse-sso?branch=master) | [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/spinen/laravel-discourse-sso/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/spinen/laravel-discourse-sso/?branch=master) |
17+
18+
## Prerequisite
19+
20+
As side from Laravel >= 5.1, there is 1 package that is required.
21+
22+
* ["cviebrock/discourse-php": "^0.9.3",](https://github.com/briannesbitt/Carbon)
23+
24+
## Install
25+
26+
Install Discourse SSO for Laravel:
27+
28+
```bash
29+
$ composer require spinen/laravel-discourse-sso
30+
```
31+
32+
### For >= Laravel 5.5, you are done with the Install
33+
34+
The package uses the auto registration feature
35+
36+
### For < Laravel 5.5, you have to register the Service Provider
37+
38+
Add the Service Provider to `config/app.php`:
39+
40+
```php
41+
'providers' => [
42+
// ...
43+
Spinen\Discourse\SsoServiceProvider::class,
44+
];
45+
```
46+
47+
## Configuration
48+
49+
All of the configuration values are stored in under a `discourse` key in `config/services.php`. Here is the array to add...
50+
51+
TODO: Put all of the config stuff here
52+
53+
## Using the package
54+
55+
TODO: Fill this in

src/SsoServiceProvider.php

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
namespace Spinen\Discourse;
4+
5+
use Illuminate\Support\ServiceProvider;
6+
7+
/**
8+
* Class SsoServiceProvider
9+
*
10+
* @package Spinen\GarbageMan
11+
*/
12+
class SsoServiceProvider extends ServiceProvider
13+
{
14+
/**
15+
* Perform post-registration booting of services.
16+
*
17+
* @return void
18+
*/
19+
public function boot()
20+
{
21+
//
22+
}
23+
24+
/**
25+
* Register the service provider.
26+
*
27+
* @return void
28+
*/
29+
public function register()
30+
{
31+
//
32+
}
33+
}

tests/SsoServiceProviderTest.php

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<?php
2+
3+
namespace Spinen\Discourse;
4+
5+
use ArrayAccess as Application;
6+
use Illuminate\Support\ServiceProvider;
7+
use Mockery;
8+
9+
class SsoServiceProviderTest extends TestCase
10+
{
11+
/**
12+
* @var Mockery\Mock
13+
*/
14+
protected $application_mock;
15+
16+
/**
17+
* @var Mockery\Mock
18+
*/
19+
protected $events_mock;
20+
21+
/**
22+
* @var Mockery\Mock
23+
*/
24+
protected $purge_command_mock;
25+
26+
/**
27+
* @var ServiceProvider
28+
*/
29+
protected $service_provider;
30+
31+
public function setUp()
32+
{
33+
parent::setUp();
34+
35+
$this->setUpMocks();
36+
37+
$this->service_provider = new SsoServiceProvider($this->application_mock);
38+
}
39+
40+
private function setUpMocks()
41+
{
42+
$this->events_mock = Mockery::mock(Events::class);
43+
$this->events_mock->shouldReceive('listen')
44+
->withAnyArgs()
45+
->andReturnNull();
46+
47+
$this->application_mock = Mockery::mock(Application::class);
48+
$this->application_mock->shouldReceive('offsetGet')
49+
->zeroOrMoreTimes()
50+
->with('events')
51+
->andReturn($this->events_mock);
52+
53+
$this->purge_command_mock = Mockery::mock(PurgeCommand::class);
54+
}
55+
56+
/**
57+
* @test
58+
* @group unit
59+
*/
60+
public function it_can_be_constructed()
61+
{
62+
$this->assertInstanceOf(SsoServiceProvider::class, $this->service_provider);
63+
}
64+
65+
/**
66+
* @test
67+
* @group unit
68+
*/
69+
public function it_boots_the_service()
70+
{
71+
$this->assertNull($this->service_provider->boot());
72+
// NOTE: It would be nice to verify that the config got set.
73+
}
74+
}

0 commit comments

Comments
 (0)