Collect subscriber IPs for 3rd party API subscriptions [MAILPOET-2575]

This commit is contained in:
wxa
2019-12-16 18:04:11 +03:00
committed by Jack Kitterhing
parent 3d465d2546
commit ac9c250b55
2 changed files with 19 additions and 2 deletions

View File

@@ -471,14 +471,26 @@ class APITest extends \MailPoetTest {
'cf_' . $custom_field->id => 'test',
];
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
$result = $this->getApi()->addSubscriber($subscriber);
expect($result['id'])->greaterThan(0);
expect($result['email'])->equals($subscriber['email']);
expect($result['cf_' . $custom_field->id])->equals('test');
expect($result['source'])->equals('api');
expect($result['subscribed_ip'])->equals($_SERVER['REMOTE_ADDR']);
expect(strlen($result['unsubscribe_token']))->equals(15);
}
function testItAllowsToOverrideSubscriberIPAddress() {
$subscriber = [
'email' => 'test-ip-2@example.com',
'subscribed_ip' => '1.2.3.4',
];
$result = $this->getApi()->addSubscriber($subscriber);
expect($result['subscribed_ip'])->equals($subscriber['subscribed_ip']);
}
function testItChecksForMandatoryCustomFields() {
CustomField::createOrUpdate([
'name' => 'custom field',