Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
BSN4 committed Apr 18, 2018
1 parent fca53b7 commit cca75aa
Show file tree
Hide file tree
Showing 12 changed files with 585 additions and 587 deletions.
7 changes: 7 additions & 0 deletions .gitignore
@@ -0,0 +1,7 @@
vendor/*
/vendor
composer.lock
/vendor
/.idea
.env
.DS_Store
14 changes: 0 additions & 14 deletions .idea/php-test-framework.xml

This file was deleted.

84 changes: 0 additions & 84 deletions .idea/php.xml

This file was deleted.

3 changes: 3 additions & 0 deletions .vscode/settings.json
@@ -0,0 +1,3 @@
{
"git.ignoreLimitWarning": true
}
15 changes: 12 additions & 3 deletions composer.json
Expand Up @@ -14,15 +14,19 @@
}
],
"require": {
"illuminate/support": "~5.1",
"illuminate/support": "5.1.* || 5.2.* || 5.3.* || 5.4.* || 5.5.* || 5.6.*",
"predis/predis": "^1.1",
"spatie/laravel-referer": "^1.3",
"torann/geoip": "^1.0",
"php" : "~5.6|~7.0"
},
"require-dev": {
"phpunit/phpunit" : ">=5.4.3",
"squizlabs/php_codesniffer": "^2.3"
"illuminate/database": "5.1.* || 5.2.* || 5.3.* || 5.4.* || 5.5.* || 5.6.*",
"orchestra/testbench": "~3.0",
"mockery/mockery": "^0.9.5 || ^1.0",
"fzaninotto/faker": "^1.6",
"doctrine/dbal": "^2.5",
"phpunit/phpunit": "^6.1"
},
"autoload": {
"psr-4": {
Expand All @@ -32,6 +36,11 @@
"src/helpers.php"
]
},
"autoload-dev": {
"psr-4": {
"if4lcon\\Bareq\\Tests\\": "tests"
}
},
"scripts": {
"test": "phpunit",
"check-style": "phpcs -p --standard=PSR2 --runtime-set ignore_errors_on_exit 1 --runtime-set ignore_warnings_on_exit 1 src tests",
Expand Down
24 changes: 24 additions & 0 deletions phpunit.xml
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="./vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
<testsuites>
<testsuite name="Unit">
<directory>./tests/Unit</directory>
</testsuite>
<testsuite name="Feature">
<directory>./tests/Feature</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./src</directory>
</whitelist>
</filter>
</phpunit>
18 changes: 9 additions & 9 deletions src/Keys.php
Expand Up @@ -20,16 +20,16 @@ class Keys
*/
public function __construct($subject)
{
$this->modelName = strtolower(str_plural(class_basename(is_string($subject) ? $subject : get_class($subject))));
$this->prefix = config('bareq.redis_keys_prefix');
$this->testing = app()->environment('testing') ? 'testing:' : '';
$this->primary = (new $subject)->getKeyName();
$this->visits = $this->visits($subject);
$this->modelName = strtolower(str_plural(class_basename(is_string($subject) ? $subject : get_class($subject))));
$this->prefix = config('bareq.redis_keys_prefix');
$this->testing = app()->environment('testing') ? 'testing:' : '';
$this->primary = (new $subject)->getKeyName();
$this->visits = $this->visits($subject);

if ($subject instanceof Model) {
$this->instanceOfModel = true;
$this->modelName = strtolower(str_singular(class_basename(get_class($subject))));
$this->id = $subject->{$subject->getKeyName()};
$this->id = $subject->{$subject->getKeyName()};
}
}

Expand All @@ -41,7 +41,7 @@ public function __construct($subject)
*/
public function visits($key)
{
return "{$this->prefix}:$this->testing" .
return "{$this->prefix}:$this->testing" .
strtolower(str_plural(class_basename(is_string($key) ? $key : get_class($key)))) .
'_visits';
}
Expand All @@ -64,7 +64,7 @@ public function ip($ip)
public function cache($limit = '*', $isLow = false)
{
$key = "{$this->prefix}:$this->testing" . "lists";
if($limit == '*') {
if ($limit == '*') {
return "{$key}:*";
}
return "{$key}:" . ($isLow ? "low" : "top") . "{$limit}_{$this->modelName}";
Expand All @@ -76,6 +76,6 @@ public function cache($limit = '*', $isLow = false)
*/
public function period($period)
{
return "{$this->visits}_{$period}";
return "{$this->visits}_{$period}";
}
}

0 comments on commit cca75aa

Please sign in to comment.