Skip to content

Commit

Permalink
Stubbing out the project
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmypuckett committed Jul 9, 2017
0 parents commit c0dafe0
Show file tree
Hide file tree
Showing 13 changed files with 472 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

[*.yml]
indent_style = space
indent_size = 2
10 changes: 10 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
* text=auto

/build export-ignore
/tests export-ignore
.gitattributes export-ignore
.gitignore export-ignore
.travis.yml export-ignore
gulpfile.js
nitpick.json export-ignore
phpunit.xml.dist export-ignore
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/vendor
/node_modules
phpunit.xml
/build
composer.lock
45 changes: 45 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
language: php

php:
- 5.5.9
- 5.5
- 5.6
- 7.0
- 7.1

env:
global:
- setup=basic

matrix:
include:
- php: 7.0
env: setup=lowest
- php: 7.0
env: setup=stable
- php: 7.1
env: setup=lowest
- php: 7.1
env: setup=stable

sudo: false

cache:
directories:
- $HOME/.composer/cache

before_install:
- phpenv config-rm xdebug.ini
- echo "extension = memcached.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
- travis_retry composer self-update

install:
- if [[ $setup = 'basic' ]]; then travis_retry composer install --no-interaction --prefer-source; fi
- if [[ $setup = 'stable' ]]; then travis_retry composer update --prefer-source --no-interaction --prefer-stable; fi
- if [[ $setup = 'lowest' ]]; then travis_retry composer update --prefer-source --no-interaction --prefer-lowest --prefer-stable; fi

before_script: mkdir -p build/logs

script: vendor/bin/phpunit

after_script: vendor/bin/coveralls -v -n
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.0.0
53 changes: 53 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"name": "spinen/laravel-discourse-sso",
"description": "Integrate Discourse SSO into Laravel.",
"keywords": [
"discourse",
"laravel",
"library",
"single sign on",
"spinen",
"sso"
],
"license": "MIT",
"authors": [
{
"name": "Jimmy Puckett",
"email": "[email protected]"
}
],
"require": {
"php": ">=5.5.9",
"cviebrock/discourse-php": "^0.9.3",
"illuminate/support": "~5.1.10|5.2.*|5.3.*|5.4.*"
},
"require-dev": {
"mockery/mockery": "^0.9.1",
"phpunit/phpunit": "~4.0|~5.0",
"psy/psysh": "^0.5.1",
"satooshi/php-coveralls": "^0.6.1|^1",
"symfony/var-dumper": "~2.7|~3.0"
},
"autoload": {
"psr-4": {
"Spinen\\Discourse\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"Spinen\\Discourse\\": "tests"
}
},
"extra": {
"laravel": {
"providers": [
"Spinen\\Discourse\\SsoServiceProvider"
],
}
},
"config": {
"sort-packages": true
},
"minimum-stability": "dev",
"prefer-stable": true
}
25 changes: 25 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
var gulp = require('gulp');
var phpunit = require('gulp-phpunit');
var notify = require('gulp-notify')

var paths = {
tests: ['tests/**/*Test.php'],
};

// Lint the shell code
gulp.task('phpunit', function () {
return gulp.src(paths.tests, {read: false})
.pipe(phpunit())
.pipe(notify(function (file) {
// TODO: Give alert of pass/fail
return file.path
}))
})

// Rerun the task when a file changes
gulp.task('watch', function() {
gulp.watch(paths.tests, ['phpunit']);
});

// The default task (called when you run `gulp` from cli)
gulp.task('default', ['phpunit']);
5 changes: 5 additions & 0 deletions nitpick.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"ignore": [
"tests/*"
]
}
58 changes: 58 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
This is the "dist(ribution)" phpunit.xml.dist file. It sets the defaults that are then over written by any files in
phpunit.xml, which is then over wrote by flags passed in via the command line. The plan is that this file is to be
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
options.
-->

<phpunit addUncoveredFilesFromWhitelist="true"
backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
processUncoveredFilesFromWhitelist="true"
stopOnFailure="false"
syntaxCheck="false"
verbose="true">

<testsuites>
<testsuite name="Laravel Discourse SSO Test Suite">
<directory>./tests/</directory>
</testsuite>
</testsuites>

<php>
<!-- <env name="VARIABLE" value="value"/> -->
</php>

<filter>
<whitelist>
<directory suffix=".php">src/</directory>
<exclude>
<!--<file>src/file.php</file>-->
<directory suffix=".php">src/config</directory>
</exclude>
</whitelist>
</filter>

<logging>
<log type="coverage-html"
target="./build/coverage"
title="Laravel Discourse SSO Test Suite"
charset="UTF-8"
yui="true"
highlight="true"
lowUpperBound="35"
highLowerBound="70"/>
<log type="coverage-clover" target="build/logs/clover.xml"/>
<log type="json" target="./build/logs/logfile.json"/>
<log type="junit" target="./build/logs/junit.xml"
logIncompleteSkipped="true"/>
</logging>
</phpunit>
55 changes: 55 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# SPINEN's Discourse SSO for Laravel

[![Latest Stable Version](https://poser.pugx.org/spinen/laravel-discourse-sso/v/stable)](https://packagist.org/packages/spinen/laravel-discourse-sso)
[![Total Downloads](https://poser.pugx.org/spinen/laravel-discourse-sso/downloads)](https://packagist.org/packages/spinen/laravel-discourse-sso)
[![Latest Unstable Version](https://poser.pugx.org/spinen/laravel-discourse-sso/v/unstable)](https://packagist.org/packages/spinen/laravel-discourse-sso)
[![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)
[![License](https://poser.pugx.org/spinen/laravel-discourse-sso/license)](https://packagist.org/packages/spinen/laravel-discourse-sso)

[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).

## Build Status

| Branch | Status | Coverage | Code Quality |
| ------ | :----: | :------: | :----------: |
| 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) |
| 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) |

## Prerequisite

As side from Laravel >= 5.1, there is 1 package that is required.

* ["cviebrock/discourse-php": "^0.9.3",](https://github.com/briannesbitt/Carbon)

## Install

Install Discourse SSO for Laravel:

```bash
$ composer require spinen/laravel-discourse-sso
```

### For >= Laravel 5.5, you are done with the Install

The package uses the auto registration feature

### For < Laravel 5.5, you have to register the Service Provider

Add the Service Provider to `config/app.php`:

```php
'providers' => [
// ...
Spinen\Discourse\SsoServiceProvider::class,
];
```

## Configuration

All of the configuration values are stored in under a `discourse` key in `config/services.php`. Here is the array to add...

TODO: Put all of the config stuff here

## Using the package

TODO: Fill this in
33 changes: 33 additions & 0 deletions src/SsoServiceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

namespace Spinen\Discourse;

use Illuminate\Support\ServiceProvider;

/**
* Class SsoServiceProvider
*
* @package Spinen\GarbageMan
*/
class SsoServiceProvider extends ServiceProvider
{
/**
* Perform post-registration booting of services.
*
* @return void
*/
public function boot()
{
//
}

/**
* Register the service provider.
*
* @return void
*/
public function register()
{
//
}
}
74 changes: 74 additions & 0 deletions tests/SsoServiceProviderTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?php

namespace Spinen\Discourse;

use ArrayAccess as Application;
use Illuminate\Support\ServiceProvider;
use Mockery;

class SsoServiceProviderTest extends TestCase
{
/**
* @var Mockery\Mock
*/
protected $application_mock;

/**
* @var Mockery\Mock
*/
protected $events_mock;

/**
* @var Mockery\Mock
*/
protected $purge_command_mock;

/**
* @var ServiceProvider
*/
protected $service_provider;

public function setUp()
{
parent::setUp();

$this->setUpMocks();

$this->service_provider = new SsoServiceProvider($this->application_mock);
}

private function setUpMocks()
{
$this->events_mock = Mockery::mock(Events::class);
$this->events_mock->shouldReceive('listen')
->withAnyArgs()
->andReturnNull();

$this->application_mock = Mockery::mock(Application::class);
$this->application_mock->shouldReceive('offsetGet')
->zeroOrMoreTimes()
->with('events')
->andReturn($this->events_mock);

$this->purge_command_mock = Mockery::mock(PurgeCommand::class);
}

/**
* @test
* @group unit
*/
public function it_can_be_constructed()
{
$this->assertInstanceOf(SsoServiceProvider::class, $this->service_provider);
}

/**
* @test
* @group unit
*/
public function it_boots_the_service()
{
$this->assertNull($this->service_provider->boot());
// NOTE: It would be nice to verify that the config got set.
}
}
Loading

0 comments on commit c0dafe0

Please sign in to comment.