Testing is working!

remotes/upstream/api-rewrite
Mike Koch 7 years ago
parent 2b792cff72
commit bbdb03d103

4
.gitignore vendored

@ -1,3 +1,7 @@
# Mods for HESK-specific files
api/vendor
# HESK Files
admin/admin_suggest_articles.php
admin/archive.php
admin/custom_statuses.php

@ -0,0 +1,38 @@
<?php
class AutoLoader {
static private $classNames = array();
/**
* Store the filename (sans extension) & full path of all ".php" files found
*/
public static function registerDirectory($dirName) {
$di = new DirectoryIterator($dirName);
foreach ($di as $file) {
if ($file->isDir() && !$file->isLink() && !$file->isDot()) {
// recurse into directories other than a few special ones
self::registerDirectory($file->getPathname());
} elseif (substr($file->getFilename(), -4) === '.php') {
// save the class name / path of a .php file found
$className = substr($file->getFilename(), 0, -4);
AutoLoader::registerClass($className, $file->getPathname());
}
}
}
public static function registerClass($className, $fileName) {
AutoLoader::$classNames[$className] = $fileName;
}
public static function loadClass($className) {
if (isset(AutoLoader::$classNames[$className])) {
require_once(AutoLoader::$classNames[$className]);
}
}
}
spl_autoload_register(array('AutoLoader', 'loadClass'));

@ -0,0 +1,34 @@
<?php
/**
* Created by PhpStorm.
* User: mkoch
* Date: 2/2/2017
* Time: 9:57 PM
*/
namespace Tests;
use BusinessLogic\Security\BannedEmail;
use BusinessLogic\Security\BanRetriever;
use DataAccess\Security\BanGateway;
use PHPUnit\Framework\TestCase;
class BanRetrieverTests extends TestCase {
function testItReturnsTrueWhenTheIpIsBanned() {
//-- Arrange
$banGateway = $this->createMock(BanGateway::class);
$banRetriever = new BanRetriever($banGateway);
$bannedEmail = new BannedEmail();
$bannedEmail->email = 'my@email.address';
$banGateway->method('getEmailBans')
->willReturn([$bannedEmail]);
//-- Act
$result = $banRetriever->isEmailBanned('my@email.address', null);
//-- Assert
$this->assertThat($result, $this->isTrue());
}
}

@ -0,0 +1,2 @@
<?php
require_once(__DIR__ . '/../bootstrap.php');

@ -0,0 +1,2 @@
<phpunit bootstrap="bootstrap.php">
</phpunit>

@ -0,0 +1,15 @@
{
"name": "mike-koch/Mods-for-HESK",
"description": "New UI and features for HESK, a free helpdesk solution",
"minimum-stability": "dev",
"license": "MIT",
"authors": [
{
"name": "Mike Koch",
"email": "mkoch227@gmail.com"
}
],
"require": {
"phpunit/phpunit": "5.7.9"
}
}

1326
api/composer.lock generated

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save