Skip to content
This repository has been archived by the owner on Nov 23, 2020. It is now read-only.

Commit

Permalink
fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hongaar committed Sep 3, 2015
1 parent 5a01738 commit f62360f
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 60 deletions.
2 changes: 1 addition & 1 deletion compact/semaltblocker.php

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions scripts/all.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/sh

echo "\nPULLING DOMAINS\n********************\n"
sh pull-domains.sh
echo "\nCOMPACTING\n********************\n"
sh compact.sh
echo "\nRUNNING TIMER\n********************\n"
sh timer.sh
echo "\nRUNNING TESTS\n********************\n"
cd ..
phpunit
cd scripts
37 changes: 0 additions & 37 deletions scripts/merge.php

This file was deleted.

3 changes: 0 additions & 3 deletions scripts/merge.sh

This file was deleted.

18 changes: 9 additions & 9 deletions src/SemaltBlocker/Blocker.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ class Blocker
{
const SEPERATOR = ':';

public static $blocklist = './../../domains/blocked';
public static $explanation = "Access to this website has been blocked because your referral is set to %s. <a href='%s'>Read why</a>";

private static $blocklist = './../../domains/blocked';
private static $debug = 'Not blocking, no reason given';

//////////////////////////////////////////
Expand Down Expand Up @@ -62,6 +62,14 @@ public static function getBlocklist()
return self::parseBlocklist(self::getBlocklistContents());
}

/**
* @return string
*/
public static function getBlocklistFilename()
{
return __DIR__ . DIRECTORY_SEPARATOR . static::$blocklist;
}

//////////////////////////////////////////
// PRIVATE FUNCTIONS //
//////////////////////////////////////////
Expand Down Expand Up @@ -152,14 +160,6 @@ private static function getHttpReferer()
return null;
}

/**
* @return string
*/
private static function getBlocklistFilename()
{
return __DIR__ . DIRECTORY_SEPARATOR . static::$blocklist;
}

/**
* @return string
*/
Expand Down
19 changes: 10 additions & 9 deletions src/SemaltBlocker/Updater.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
*/
class Updater
{
public static $blocklist = './../../domains/blocked';
public static $ttl = 604800; // = 60 * 60 * 24 * 7 = 7 days
public static $updateUrl = 'https://raw.githubusercontent.com/nabble/semalt-blocker/master/domains/blocked';

private static $blocklist = './../../domains/blocked';

//////////////////////////////////////////
// PUBLIC API //
//////////////////////////////////////////
Expand Down Expand Up @@ -49,6 +50,14 @@ public static function getNewDomainList()
return $domains;
}

/**
* @return string
*/
public static function getBlocklistFilename()
{
return __DIR__ . DIRECTORY_SEPARATOR . static::$blocklist;
}

//////////////////////////////////////////
// PRIVATE FUNCTIONS //
//////////////////////////////////////////
Expand Down Expand Up @@ -77,12 +86,4 @@ private static function isOutdated()
{
return filemtime(self::getBlocklistFilename()) < (time() - self::$ttl);
}

/**
* @return string
*/
private static function getBlocklistFilename()
{
return __DIR__ . DIRECTORY_SEPARATOR . static::$blocklist;
}
}
2 changes: 1 addition & 1 deletion tests/SemaltUpdaterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class SemaltUpdaterTest extends PHPUnit_Framework_TestCase

public function setUp()
{
$this->blockFile = (\Nabble\SemaltBlocker\Updater::$blocklist = './domains/blocked');
$this->blockFile = \Nabble\SemaltBlocker\Updater::getBlocklistFilename();
$this->domainUrl = \Nabble\SemaltBlocker\Updater::$updateUrl;
}

Expand Down

0 comments on commit f62360f

Please sign in to comment.