-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from challgren/add-tests
Improve testing and coverage
- Loading branch information
Showing
11 changed files
with
303 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Created by .ignore support plugin (hsz.mobi) | ||
### Windows template | ||
# Windows thumbnail cache files | ||
Thumbs.db | ||
ehthumbs.db | ||
ehthumbs_vista.db | ||
|
||
# Dump file | ||
*.stackdump | ||
|
||
# Folder config file | ||
[Dd]esktop.ini | ||
|
||
# Windows shortcuts | ||
*.lnk | ||
### user template | ||
|
||
# IntelliJ project files | ||
.idea | ||
*.iml | ||
out | ||
gen | ||
|
||
### CakePHP template | ||
# CakePHP 3 | ||
|
||
/vendor/* | ||
/config/app.php | ||
|
||
/tmp | ||
|
||
### macOS template | ||
# General | ||
.DS_Store | ||
.AppleDouble | ||
.LSOverride | ||
|
||
# Thumbnails | ||
._* | ||
/composer.lock | ||
/phpunit.xml | ||
/phpunit.phar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
language: php | ||
|
||
sudo: false | ||
|
||
php: | ||
- 5.6 | ||
- 7.0 | ||
- 7.3 | ||
|
||
env: | ||
matrix: | ||
- DB=mysql db_dsn='mysql://[email protected]/cakephp_test' | ||
global: | ||
- DEFAULT=1 | ||
|
||
matrix: | ||
fast_finish: true | ||
|
||
include: | ||
- php: 7.1 | ||
env: DB=pgsql db_dsn='postgres://[email protected]/cakephp_test' | ||
|
||
- php: 7.2 | ||
env: DB=sqlite db_dsn='sqlite:///:memory:' | ||
|
||
- php: 5.6 | ||
env: PREFER_LOWEST=1 | ||
|
||
- php: 7.2 | ||
env: CHECKS=1 DEFAULT=0 | ||
|
||
- php: 7.2 | ||
env: CODECOVERAGE=1 DEFAULT=0 | ||
|
||
before_script: | ||
- if [[ $PREFER_LOWEST != 1 ]]; then composer install --prefer-source --no-interaction ; fi | ||
- if [[ $PREFER_LOWEST == 1 ]]; then composer update --prefer-dist --no-interaction --prefer-lowest --prefer-stable ; fi | ||
|
||
- if [[ $CHECKS != 1 ]]; then composer require phpunit/phpunit:"^5.7.14|^6.0"; fi | ||
|
||
- sh -c "if [ '$DB' = 'mysql' ]; then mysql -e 'CREATE DATABASE cakephp_test;'; fi" | ||
- sh -c "if [ '$DB' = 'pgsql' ]; then psql -c 'CREATE DATABASE cakephp_test;' -U postgres; fi" | ||
|
||
- phpenv rehash | ||
- set +H | ||
- cp phpunit.xml.dist phpunit.xml | ||
|
||
script: | ||
- if [[ $DEFAULT == 1 ]]; then vendor/bin/phpunit; fi | ||
|
||
- if [[ $CHECKS == 1 ]]; then composer phpstan-setup && composer phpstan ; fi | ||
- if [[ $CHECKS == 1 ]]; then composer cs-check ; fi | ||
|
||
- if [[ $CODECOVERAGE == 1 ]]; then vendor/bin/phpunit --coverage-clover=clover.xml || true; fi | ||
- if [[ $CODECOVERAGE == 1 ]]; then wget -O codecov.sh https://codecov.io/bash; fi | ||
- if [[ $CODECOVERAGE == 1 ]]; then bash codecov.sh; fi | ||
|
||
notifications: | ||
email: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
/** | ||
* Created by PhpStorm. | ||
* User: challgren | ||
* Date: 2019-01-02 | ||
* Time: 05:52 | ||
*/ | ||
|
||
namespace CakeImpersonate; | ||
|
||
use Cake\Core\BasePlugin; | ||
|
||
class Plugin extends BasePlugin | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
/** | ||
* Created by PhpStorm. | ||
* User: challgren | ||
* Date: 2019-01-02 | ||
* Time: 05:57 | ||
*/ | ||
|
||
namespace CakeImpersonate\Test\Fixture; | ||
|
||
use Cake\TestSuite\Fixture\TestFixture; | ||
|
||
class UsersFixture extends TestFixture | ||
{ | ||
/** | ||
* Fields | ||
* | ||
* @var array | ||
*/ | ||
public $fields = [ | ||
'id' => ['type' => 'integer'], | ||
'name' => ['type' => 'string', 'null' => true], | ||
'password' => ['type' => 'string', 'null' => true], | ||
'active' => ['type' => 'boolean', 'null' => true], | ||
'_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]] | ||
]; | ||
/** | ||
* Records | ||
* | ||
* @var array | ||
*/ | ||
public $records = [ | ||
[ | ||
'id' => 1, | ||
'name' => 'test-user', | ||
'password' => '12345678', | ||
'active' => true, | ||
], | ||
[ | ||
'id' => 2, | ||
'name' => 'tester', | ||
'password' => '12345678', | ||
'active' => false, | ||
], | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
parameters: | ||
autoload_files: | ||
- %rootDir%/../../../tests/bootstrap.php | ||
excludes_analyse: | ||
- %rootDir%/../../../src/TestSuite/* | ||
|
||
services: | ||
- | ||
class: Cake\PHPStan\AssociationTableMixinClassReflectionExtension |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
/** | ||
* Created by PhpStorm. | ||
* User: challgren | ||
* Date: 2019-01-02 | ||
* Time: 05:28 | ||
*/ | ||
|
||
namespace App\Controller; | ||
|
||
use Cake\Controller\Controller; | ||
|
||
/** | ||
* Use Controller instead of AppController to avoid conflicts | ||
* | ||
* @property \CakeImpersonate\Controller\Component\ImpersonateComponent $Impersonate | ||
*/ | ||
class ImpersonateTestController extends Controller | ||
{ | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function initialize() | ||
{ | ||
$this->loadComponent('Auth'); | ||
$this->loadComponent('CakeImpersonate.Impersonate'); | ||
parent::initialize(); | ||
} | ||
} |
Oops, something went wrong.