2017-11-27 03:14:16 +01:00
|
|
|
<?php
|
|
|
|
namespace SilverStripe\ExternalLinks\Tests\Stubs;
|
|
|
|
|
2017-11-27 21:35:31 +01:00
|
|
|
use SilverStripe\Dev\TestOnly;
|
2017-11-27 03:14:16 +01:00
|
|
|
use SilverStripe\ExternalLinks\Tasks\LinkChecker;
|
|
|
|
|
2017-11-27 21:35:31 +01:00
|
|
|
class PretendLinkChecker implements LinkChecker, TestOnly
|
2017-11-27 03:14:16 +01:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|