Skip to content

Commit

Permalink
Minor fix
Browse files Browse the repository at this point in the history
Signed-off-by: Sam Poyigi <[email protected]>
  • Loading branch information
sampoyigi committed Dec 30, 2024
1 parent 222b630 commit 5262444
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 27 deletions.
2 changes: 1 addition & 1 deletion src/Models/Banner.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Banner extends Model
*/
protected $primaryKey = 'banner_id';

protected $fillable = ['name', 'type', 'click_url', 'language_id', 'alt_text', 'image_code', 'custom_code', 'status'];
protected $fillable = ['name', 'code', 'type', 'click_url', 'language_id', 'alt_text', 'image_code', 'custom_code', 'status'];

public $relation = [
'belongsTo' => [
Expand Down
2 changes: 1 addition & 1 deletion src/Models/MailchimpSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ class MailchimpSettings extends Model

public static function isConfigured()
{
return strlen(self::get('api_key', '')) && strlen(self::get('list_id', ''));
return !empty(self::get('api_key', ''));

Check failure on line 17 in src/Models/MailchimpSettings.php

View workflow job for this annotation

GitHub Actions / php-tests (8.2) / PHP Tests

Ignored error pattern #^Call to an undefined static method Igniter\\Frontend\\Models\\MailchimpSettings\:\:get\(\)\.$# in path /home/runner/work/ti-ext-frontend/ti-ext-frontend/src/Models/MailchimpSettings.php is expected to occur 2 times, but occurred only 1 time.

Check failure on line 17 in src/Models/MailchimpSettings.php

View workflow job for this annotation

GitHub Actions / php-tests (8.3) / PHP Tests

Ignored error pattern #^Call to an undefined static method Igniter\\Frontend\\Models\\MailchimpSettings\:\:get\(\)\.$# in path /home/runner/work/ti-ext-frontend/ti-ext-frontend/src/Models/MailchimpSettings.php is expected to occur 2 times, but occurred only 1 time.
}
}
4 changes: 2 additions & 2 deletions src/Models/Subscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ public static function subscribe(string $email, ?string $listId = null): static
public function subscribeToMailchimp(?string $listId = null, array $options = [])
{
throw_unless(MailchimpSettings::isConfigured(), new ApplicationException(
'MailChimp List ID is missing. Enter your mailchimp api key and list ID from the admin settings page'
'MailChimp List ID is missing. Enter your mailchimp api key and list ID from the admin settings page',
));

$listId = (string)MailchimpSettings::get('list_id');
$listId = $listId ?? (string)MailchimpSettings::get('list_id');

$response = resolve(MailChimp::class)->post("lists/$listId/members", array_merge([
'email_address' => $this->email,
Expand Down
2 changes: 1 addition & 1 deletion tests/Models/BannerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
->toContain(Switchable::class)
->and($banner->getTable())->toBe('igniter_frontend_banners')
->and($banner->getKeyName())->toBe('banner_id')
->and($banner->getFillable())->toContain('name', 'type', 'click_url', 'language_id', 'alt_text', 'image_code', 'custom_code', 'status')
->and($banner->getFillable())->toContain('name', 'code', 'type', 'click_url', 'language_id', 'alt_text', 'image_code', 'custom_code', 'status')
->and($banner->relation['belongsTo'])->toBe([
'language' => \Igniter\System\Models\Language::class,
])
Expand Down
22 changes: 0 additions & 22 deletions tests/Models/MailchimpSettingsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,28 +27,6 @@
expect($result)->toBeFalse();
});

it('returns false when list_id is not configured', function() {
MailchimpSettings::set([
'api_key' => 'some-api-key',
'list_id' => '',
]);

$result = MailchimpSettings::isConfigured();

expect($result)->toBeFalse();
});

it('returns false when both api_key and list_id are not configured', function() {
MailchimpSettings::set([
'api_key' => '',
'list_id' => '',
]);

$result = MailchimpSettings::isConfigured();

expect($result)->toBeFalse();
});

it('configures captcha settings model correctly', function() {
$model = new MailchimpSettings;

Expand Down

0 comments on commit 5262444

Please sign in to comment.