SproutCMS

This is the code documentation for the SproutCMS project

source of /sprout/tests/WorkerLinkCheckerTest.php

  1. <?php
  2. /*
  3.  * Copyright (C) 2017 Karmabunny Pty Ltd.
  4.  *
  5.  * This file is a part of SproutCMS.
  6.  *
  7.  * SproutCMS is free software: you can redistribute it and/or modify it under the terms
  8.  * of the GNU General Public License as published by the Free Software Foundation, either
  9.  * version 2 of the License, or (at your option) any later version.
  10.  *
  11.  * For more information, visit <http://getsproutcms.com>.
  12.  */
  13.  
  14. use Sprout\Helpers\WorkerLinkChecker;
  15.  
  16. class WorkerLinkCheckerTest extends PHPUnit_Framework_TestCase
  17. {
  18.  
  19. /**
  20.   * URLs which are okay
  21.   **/
  22. public function dataCheckOkay()
  23. {
  24. return array(
  25. array('http://www.google.com/'),
  26. array('http://www.google.com'),
  27. array('https://www.google.com'),
  28. array('mailto:bob@example.com'),
  29. array('ftp://mirror.internode.on.net/pub/'),
  30. array('http://www.google.com/intl/en/policies/terms'),
  31. array('http://www.google.com/intl/en/policies/terms/'),
  32. array('https://www.google.com/intl/en/policies/terms'),
  33. array('https://www.google.com/intl/en/policies/terms/'),
  34. );
  35. }
  36.  
  37.  
  38. /**
  39.   * URLs which are okay
  40.   * @dataProvider dataCheckOkay
  41.   **/
  42. public function testCheckOkay($url)
  43. {
  44. $obj = new WorkerLinkChecker();
  45. $this->assertTrue($obj->checkUrl($url));
  46. }
  47.  
  48.  
  49. /**
  50.   * URLs which are not okay
  51.   **/
  52. public function dataCheckBad()
  53. {
  54. return array(
  55. array('http://www.google.com/asdfghjklasdfghjkladfghjk'),
  56. array('http://'),
  57. array('htt p : // thejosh.info'),
  58. array('gdskfsfnsafnsknf://'),
  59. );
  60. }
  61.  
  62.  
  63. /**
  64.   * URLs which are not okay
  65.   * @dataProvider dataCheckBad
  66.   **/
  67. public function testCheckBad($url)
  68. {
  69. $obj = new WorkerLinkChecker();
  70. $this->assertNotTrue($obj->checkUrl($url));
  71. }
  72.  
  73. }
  74.