|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Cleantalk\Antispam\Integrations; |
| 4 | + |
| 5 | +use Cleantalk\ApbctWP\Variables\Get; |
| 6 | +use Cleantalk\ApbctWP\Variables\Post; |
| 7 | +use PHPUnit\Framework\TestCase; |
| 8 | + |
| 9 | +class TestEasyDigitalDownloads extends TestCase |
| 10 | +{ |
| 11 | + private $integration; |
| 12 | + |
| 13 | + protected function setUp(): void |
| 14 | + { |
| 15 | + parent::setUp(); |
| 16 | + $this->integration = new EasyDigitalDownloads(); |
| 17 | + } |
| 18 | + |
| 19 | + protected function tearDown(): void |
| 20 | + { |
| 21 | + // Clean up global state |
| 22 | + $_POST = []; |
| 23 | + $_GET = []; |
| 24 | + Post::getInstance()->variables = []; |
| 25 | + Get::getInstance()->variables = []; |
| 26 | + parent::tearDown(); |
| 27 | + } |
| 28 | + |
| 29 | + public function testGetDataForCheckingRegisterPage() |
| 30 | + { |
| 31 | + $_POST['edd_action'] = 'user_register'; |
| 32 | + $_POST['edd_user_login'] = 'John'; |
| 33 | + $_POST['edd_user_email'] = 'john.doe@example.com'; |
| 34 | + |
| 35 | + $result = $this->integration->getDataForChecking(null); |
| 36 | + |
| 37 | + $this->assertIsArray($result); |
| 38 | + $this->assertEquals('john.doe@example.com', $result['email']); |
| 39 | + $this->assertEquals('', $result['nickname']); // NickName not detected at that integration |
| 40 | + $this->assertTrue($result['register']); |
| 41 | + } |
| 42 | + |
| 43 | + public function testGetDataForCheckingRegisterDuringCheckout() |
| 44 | + { |
| 45 | + $_POST['edd-process-checkout-nonce'] = 'user_register'; |
| 46 | + $_POST['edd_first'] = 'John'; |
| 47 | + $_POST['edd_last'] = 'Doe'; |
| 48 | + $_POST['edd_email'] = 'john.doe@example.com'; |
| 49 | + |
| 50 | + $result = $this->integration->getDataForChecking(null); |
| 51 | + |
| 52 | + $this->assertIsArray($result); |
| 53 | + $this->assertEquals('john.doe@example.com', $result['email']); |
| 54 | + $this->assertEquals('', $result['nickname']); // NickName not detected at that integration |
| 55 | + $this->assertTrue($result['register']); |
| 56 | + } |
| 57 | + |
| 58 | + public function testGetDataForCheckingRegisterCommon() |
| 59 | + { |
| 60 | + $_POST['edd_user_login'] = 'John'; |
| 61 | + $_POST['edd_user_email'] = 'john.doe@example.com'; |
| 62 | + |
| 63 | + $result = $this->integration->getDataForChecking(['user_email' => 'any_email_no_sense']); |
| 64 | + |
| 65 | + $this->assertIsArray($result); |
| 66 | + $this->assertEquals('john.doe@example.com', $result['email']); |
| 67 | + $this->assertEquals('', $result['nickname']); // NickName not detected at that integration |
| 68 | + $this->assertTrue($result['register']); |
| 69 | + } |
| 70 | +} |
0 commit comments