Skip to content

Commit 66cb9ae

Browse files
committed
Completed tests
1 parent 57bbb00 commit 66cb9ae

File tree

2 files changed

+72
-4
lines changed

2 files changed

+72
-4
lines changed

src/ConvertKit_API.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -410,8 +410,8 @@ public function get_forms(
410410
return $this->get(
411411
endpoint: 'forms',
412412
args: $this->build_total_count_and_pagination_params(
413-
params: [
414-
'type' => 'embed',
413+
params: [
414+
'type' => 'embed',
415415
'status' => $status,
416416
],
417417
include_total_count: $include_total_count,
@@ -447,8 +447,8 @@ public function get_landing_pages(
447447
return $this->get(
448448
endpoint: 'forms',
449449
args: $this->build_total_count_and_pagination_params(
450-
params: [
451-
'type' => 'hosted',
450+
params: [
451+
'type' => 'hosted',
452452
'status' => $status,
453453
],
454454
include_total_count: $include_total_count,

tests/ConvertKitAPITest.php

+68
Original file line numberDiff line numberDiff line change
@@ -746,6 +746,49 @@ public function testGetForms()
746746

747747
// Assert form is not a landing page i.e embed.
748748
$this->assertEquals($form['type'], 'embed');
749+
750+
// Assert form is not archived.
751+
$this->assertFalse($form['archived']);
752+
}
753+
}
754+
755+
/**
756+
* Test that get_forms() returns the expected data when
757+
* the status is set to archived.
758+
*
759+
* @since 2.0.0
760+
*
761+
* @return void
762+
*/
763+
public function testGetFormsWithArchivedStatus()
764+
{
765+
$result = $this->api->get_forms(
766+
status: 'archived'
767+
);
768+
769+
// Assert forms and pagination exist.
770+
$this->assertDataExists($result, 'forms');
771+
$this->assertPaginationExists($result);
772+
773+
// Iterate through each form, confirming no landing pages were included.
774+
foreach ($result->forms as $form) {
775+
$form = get_object_vars($form);
776+
777+
// Assert shape of object is valid.
778+
$this->assertArrayHasKey('id', $form);
779+
$this->assertArrayHasKey('name', $form);
780+
$this->assertArrayHasKey('created_at', $form);
781+
$this->assertArrayHasKey('type', $form);
782+
$this->assertArrayHasKey('format', $form);
783+
$this->assertArrayHasKey('embed_js', $form);
784+
$this->assertArrayHasKey('embed_url', $form);
785+
$this->assertArrayHasKey('archived', $form);
786+
787+
// Assert form is not a landing page i.e embed.
788+
$this->assertEquals($form['type'], 'embed');
789+
790+
// Assert form is not archived.
791+
$this->assertTrue($form['archived']);
749792
}
750793
}
751794

@@ -863,9 +906,34 @@ public function testGetLandingPages()
863906

864907
// Assert form is a landing page i.e. hosted.
865908
$this->assertEquals($form['type'], 'hosted');
909+
910+
// Assert form is not archived.
911+
$this->assertFalse($form['archived']);
866912
}
867913
}
868914

915+
/**
916+
* Test that get_landing_pages() returns the expected data when
917+
* the status is set to archived.
918+
*
919+
* @since 2.0.0
920+
*
921+
* @return void
922+
*/
923+
public function testGetLandingPagesWithArchivedStatus()
924+
{
925+
$result = $this->api->get_forms(
926+
status: 'archived'
927+
);
928+
929+
// Assert forms and pagination exist.
930+
$this->assertDataExists($result, 'forms');
931+
$this->assertPaginationExists($result);
932+
933+
// Assert no landing pages are returned, as the account doesn't have any archived landing pages.
934+
$this->assertCount(0, $result->forms);
935+
}
936+
869937
/**
870938
* Test that get_landing_pages() returns the expected data
871939
* when the total count is included.

0 commit comments

Comments
 (0)