silverstripe-externallinks/tests/Stubs/PretendLinkChecker.php
Dylan Wagstaff 98dac9b314 Update unit tests to be rid of Phockito
This odd dependency is causing inclusion issues to do with namespacing and
the ability to work well with the framework (according to the dependency's
readme). The usage of the tool in this case adds no value, as it's
performing purely stub type work, rather than mock work. So instead we can
use an actual stub (simply return test values depending on input) and have
everything work well.

After removing the Phockito dependency it was found that the tests that
would skip when it isn't present were actually in a failing state. So they
had to be repaired too, mostly through the use of fixing the poor code
that was causing them to fail (as opposed to being bad tests). This is
both configuration and proceedural work.
2017-11-27 15:14:16 +13:00

29 lines
766 B
PHP

<?php
namespace SilverStripe\ExternalLinks\Tests\Stubs;
use SilverStripe\ExternalLinks\Tasks\LinkChecker;
class PretendLinkChecker implements LinkChecker
{
public function checkLink($href)
{
switch ($href) {
case 'http://www.working.com':
return 200;
case 'http://www.broken.com':
return 403;
case 'http://www.nodomain.com':
return 0;
case '/internal/link':
case '[sitetree_link,id=9999]':
case 'home':
case 'broken-internal':
case '[sitetree_link,id=1]':
return null;
case 'http://www.broken.com/url/thing':
default:
return 404;
}
}
}