@@ -3281,6 +3281,105 @@ public function testGetSubscriberTagsPagination()
32813281 $ this ->assertCount (1 , $ result ->tags );
32823282 }
32833283
3284+ /**
3285+ * Test that get_email_templates() returns the expected data.
3286+ *
3287+ * @since 2.0.0
3288+ *
3289+ * @return void
3290+ */
3291+ public function testGetEmailTemplates ()
3292+ {
3293+ $ result = $ this ->api ->get_email_templates ();
3294+
3295+ // Assert email templates and pagination exist.
3296+ $ this ->assertDataExists ($ result , 'email_templates ' );
3297+ $ this ->assertPaginationExists ($ result );
3298+ }
3299+
3300+ /**
3301+ * Test that get_email_templates() returns the expected data
3302+ * when the total count is included.
3303+ *
3304+ * @since 1.0.0
3305+ *
3306+ * @return void
3307+ */
3308+ public function testGetEmailTemplatesWithTotalCount ()
3309+ {
3310+ $ result = $ this ->api ->get_email_templates (
3311+ include_total_count: true
3312+ );
3313+
3314+ // Assert email templates and pagination exist.
3315+ $ this ->assertDataExists ($ result , 'email_templates ' );
3316+ $ this ->assertPaginationExists ($ result );
3317+
3318+ // Assert total count is included.
3319+ $ this ->assertArrayHasKey ('total_count ' , get_object_vars ($ result ->pagination ));
3320+ $ this ->assertGreaterThan (0 , $ result ->pagination ->total_count );
3321+ }
3322+
3323+ /**
3324+ * Test that get_email_templates() returns the expected data
3325+ * when pagination parameters and per_page limits are specified.
3326+ *
3327+ * @since 2.0.0
3328+ *
3329+ * @return void
3330+ */
3331+ public function testGetEmailTemplatesPagination ()
3332+ {
3333+ $ result = $ this ->api ->get_email_templates (
3334+ per_page: 1
3335+ );
3336+
3337+ // Assert email templates and pagination exist.
3338+ $ this ->assertDataExists ($ result , 'email_templates ' );
3339+ $ this ->assertPaginationExists ($ result );
3340+
3341+ // Assert a single email template was returned.
3342+ $ this ->assertCount (1 , $ result ->email_templates );
3343+
3344+ // Assert has_previous_page and has_next_page are correct.
3345+ $ this ->assertFalse ($ result ->pagination ->has_previous_page );
3346+ $ this ->assertTrue ($ result ->pagination ->has_next_page );
3347+
3348+ // Use pagination to fetch next page.
3349+ $ result = $ this ->api ->get_email_templates (
3350+ per_page: 1 ,
3351+ after_cursor: $ result ->pagination ->end_cursor
3352+ );
3353+
3354+ // Assert email templates and pagination exist.
3355+ $ this ->assertDataExists ($ result , 'email_templates ' );
3356+ $ this ->assertPaginationExists ($ result );
3357+
3358+ // Assert a single email template was returned.
3359+ $ this ->assertCount (1 , $ result ->email_templates );
3360+
3361+ // Assert has_previous_page and has_next_page are correct.
3362+ $ this ->assertTrue ($ result ->pagination ->has_previous_page );
3363+ $ this ->assertTrue ($ result ->pagination ->has_next_page );
3364+
3365+ // Use pagination to fetch previous page.
3366+ $ result = $ this ->api ->get_email_templates (
3367+ per_page: 1 ,
3368+ before_cursor: $ result ->pagination ->start_cursor
3369+ );
3370+
3371+ // Assert email templates and pagination exist.
3372+ $ this ->assertDataExists ($ result , 'email_templates ' );
3373+ $ this ->assertPaginationExists ($ result );
3374+
3375+ // Assert a single email template was returned.
3376+ $ this ->assertCount (1 , $ result ->email_templates );
3377+
3378+ // Assert has_previous_page and has_next_page are correct.
3379+ $ this ->assertFalse ($ result ->pagination ->has_previous_page );
3380+ $ this ->assertTrue ($ result ->pagination ->has_next_page );
3381+ }
3382+
32843383 /**
32853384 * Test that create_broadcast(), update_broadcast() and destroy_broadcast() works
32863385 * when specifying valid published_at and send_at values.
0 commit comments