| Total Complexity | 1 |
| Total Lines | 42 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 10 | class StaticCallingTraitTest extends TestCase |
||
| 11 | { |
||
| 12 | /** |
||
| 13 | * @var SafeUrls |
||
| 14 | */ |
||
| 15 | private $safeUrls; |
||
| 16 | |||
| 17 | private $urlsToTest; |
||
| 18 | |||
| 19 | protected function setUp():void |
||
| 20 | { |
||
| 21 | parent::setUp(); |
||
| 22 | |||
| 23 | $this->safeUrls = new SafeUrls(); |
||
| 24 | $this->urlsToTest = [ |
||
| 25 | 'https://testsafebrowsing.appspot.com/s/phishing.html', |
||
| 26 | 'https://testsafebrowsing.appspot.com/s/malware.html', |
||
| 27 | 'http://testsafebrowsing.appspot.com/apiv4/ANY_PLATFORM/MALWARE/URL/', |
||
| 28 | 'http://testsafebrowsing.appspot.com/apiv4/ANY_PLATFORM/SOCIAL_ENGINEERING/URL/', |
||
| 29 | 'http://malware.testing.google.test/testing/malware/', |
||
| 30 | ]; |
||
| 31 | } |
||
| 32 | |||
| 33 | public function testStaticCallingMethod() |
||
| 34 | { |
||
| 35 | $className = SafeUrls::class; |
||
| 36 | $methodName = 'check'; |
||
| 37 | |||
| 38 | $testClass = new class() { |
||
| 39 | use StaticCalling; |
||
| 40 | }; |
||
| 41 | |||
| 42 | // Only testing with returned HTTP status, as Google Safebrowsing API not working as |
||
| 43 | // documented. See tests\Libraries\Curl\CurlTest testMalwareSocialEngineeringAnyPlatformUrl(). |
||
| 44 | $expected = 200; |
||
| 45 | $actual = json_decode( |
||
| 46 | $testClass->callStatic( |
||
| 47 | $className, $methodName, $this->urlsToTest |
||
| 48 | ), true |
||
| 49 | )['status']; |
||
| 50 | |||
| 51 | $this->assertEquals($expected, $actual); |
||
| 52 | } |
||
| 54 |