@@ -54,8 +54,8 @@ public function test_overwrite_invalidation_item_by_post_name() {
5454 }
5555 return $ items ;
5656 }, 10 , 2 );
57-
58- // ケース1: 上書きされるべきケース
57+
58+ // Case 1: Item should be overwritten by filter.
5959 $ post1 = $ this ->factory ->post ->create_and_get ( array (
6060 'post_status ' => 'publish ' ,
6161 'post_name ' => 'should-overwritten ' ,
@@ -68,8 +68,8 @@ public function test_overwrite_invalidation_item_by_post_name() {
6868 ),
6969 'Quantity ' => 1
7070 ], $ result [ 'InvalidationBatch ' ][ 'Paths ' ]);
71-
72- // ケース2: 上書きされないケース
71+
72+ // Case 2: Item should not be overwritten.
7373 $ post2 = $ this ->factory ->post ->create_and_get ( array (
7474 'post_status ' => 'publish ' ,
7575 'post_name ' => 'should-not-overwritten ' ,
@@ -101,6 +101,31 @@ public function test_get_the_un_published_post_invalidation_paths() {
101101 ) , $ result [ 'InvalidationBatch ' ][ 'Paths ' ] );
102102 }
103103
104+ public function test_get_the_published_to_draft_post_invalidation_paths () {
105+ $ post_id = $ this ->factory ->post ->create ( array (
106+ 'post_status ' => 'publish ' ,
107+ 'post_name ' => 'published-to-draft ' ,
108+ 'post_type ' => 'post ' ,
109+ ) );
110+
111+ wp_update_post ( array (
112+ 'ID ' => $ post_id ,
113+ 'post_status ' => 'draft ' ,
114+ ) );
115+
116+ $ post = get_post ( $ post_id );
117+
118+ $ target = new AWS \Invalidation_Batch_Service ();
119+ $ result = $ target ->create_batch_by_post ( 'localhost ' , 'EXXX ' , $ post );
120+ $ this ->assertEquals ( array (
121+ 'Items ' => array (
122+ 'localhost ' ,
123+ '/published-to-draft/* ' ,
124+ ),
125+ 'Quantity ' => 2
126+ ), $ result [ 'InvalidationBatch ' ][ 'Paths ' ] );
127+ }
128+
104129 public function test_get_invalidation_path_for_all () {
105130 $ target = new AWS \Invalidation_Batch_Service ();
106131 $ result = $ target ->create_batch_for_all ( 'EXXXX ' );
@@ -113,7 +138,7 @@ public function test_get_invalidation_path_for_all() {
113138 }
114139
115140 public function test_create_batch_by_posts () {
116- // ケース1: 1つの投稿
141+ // Case 1: Single post.
117142 $ post1 = $ this ->factory ->post ->create_and_get ( array (
118143 'post_status ' => 'publish ' ,
119144 'post_name ' => 'hello-world ' ,
@@ -128,8 +153,8 @@ public function test_create_batch_by_posts() {
128153 ],
129154 "Quantity " => 2
130155 ], $ result [ 'InvalidationBatch ' ][ 'Paths ' ]);
131-
132- // ケース2: 複数の投稿
156+
157+ // Case 2: Multiple posts.
133158 $ post2 = $ this ->factory ->post ->create_and_get ( array (
134159 'post_status ' => 'publish ' ,
135160 'post_name ' => 'see-you ' ,
@@ -138,7 +163,7 @@ public function test_create_batch_by_posts() {
138163 'post_status ' => 'trash ' ,
139164 'post_name ' => 'good-bye ' ,
140165 ) );
141-
166+
142167 $ result = $ target ->create_batch_by_posts ( 'localhost ' , 'EXXXX ' , [$ post2 , $ post3 ] );
143168 $ this ->assertEquals ([
144169 "Items " => [
@@ -152,17 +177,17 @@ public function test_create_batch_by_posts() {
152177
153178 /**
154179 * Test Case: c3_invalidation_post_batch_home_path filter hook functionality
155- *
180+ *
156181 * Overview:
157182 * This test verifies that the c3_invalidation_post_batch_home_path filter hook
158183 * correctly allows customization of the home path during single post invalidation.
159- *
184+ *
160185 * Expected Behavior:
161186 * - The filter should receive the original home path and post object as parameters
162187 * - When the post slug matches 'custom-home', the filter should return '/custom-homepage/'
163188 * - The invalidation batch should contain both the custom home path and the post-specific path
164189 * - Other posts should not be affected by this filter condition
165- *
190+ *
166191 * Test Method:
167192 * 1. Register a filter that modifies home path for posts with slug 'custom-home'
168193 * 2. Create a test post with the matching slug 'custom-home'
@@ -197,17 +222,17 @@ public function test_c3_invalidation_post_batch_home_path_filter() {
197222
198223 /**
199224 * Test Case: c3_invalidation_posts_batch_home_path filter hook functionality
200- *
225+ *
201226 * Overview:
202227 * This test verifies that the c3_invalidation_posts_batch_home_path filter hook
203228 * correctly allows customization of the home path during multiple posts invalidation.
204- *
229+ *
205230 * Expected Behavior:
206231 * - The filter should receive the original home path and array of post objects as parameters
207232 * - When more than 1 post is being processed, the filter should return '/bulk-update-homepage/'
208233 * - The invalidation batch should contain the custom home path plus individual post paths
209234 * - Single post batches should not trigger this filter condition
210- *
235+ *
211236 * Test Method:
212237 * 1. Register a filter that modifies home path when processing multiple posts (count > 1)
213238 * 2. Create two test posts with different slugs ('post-one' and 'post-two')
@@ -247,17 +272,17 @@ public function test_c3_invalidation_posts_batch_home_path_filter() {
247272
248273 /**
249274 * Test Case: c3_invalidation_manual_batch_all_path filter hook functionality
250- *
275+ *
251276 * Overview:
252277 * This test verifies that the c3_invalidation_manual_batch_all_path filter hook
253278 * correctly allows customization of the path pattern used for manual "clear all cache" operations.
254- *
279+ *
255280 * Expected Behavior:
256281 * - The filter should receive the default all-clear path pattern ('/*') as a parameter
257282 * - The filter should be able to return a custom path pattern for clearing all cache
258283 * - The invalidation batch should contain only the custom path pattern
259284 * - This provides more granular control over manual cache clearing operations
260- *
285+ *
261286 * Test Method:
262287 * 1. Register a filter that replaces the default '/*' pattern with '/custom-all-path/*'
263288 * 2. Call create_batch_for_all() method to trigger manual all-cache clearing
@@ -283,18 +308,18 @@ public function test_c3_invalidation_manual_batch_all_path_filter() {
283308
284309 /**
285310 * Test Case: WordPress subdirectory installation support
286- *
311+ *
287312 * Overview:
288313 * This test verifies that the new path adjustment hooks correctly handle WordPress
289314 * installations in subdirectories by automatically including subdirectory paths
290315 * in invalidation requests through WordPress's standard home_url() function.
291- *
316+ *
292317 * Expected Behavior:
293318 * - When WordPress is installed in a subdirectory (e.g., /blog/), home_url() should return the subdirectory path
294319 * - The c3_invalidation_post_batch_home_path filter should receive the subdirectory path automatically
295320 * - Invalidation batches should include both the subdirectory home path and post-specific paths
296321 * - The plugin should work seamlessly without manual configuration for subdirectory installations
297- *
322+ *
298323 * Test Method:
299324 * 1. Mock WordPress home_url() to simulate a subdirectory installation (/blog/)
300325 * 2. Register a filter to verify the subdirectory path is correctly passed to the hook
@@ -335,17 +360,17 @@ public function test_subdirectory_installation_support() {
335360
336361 /**
337362 * Test Case: Subdirectory-specific path customization
338- *
363+ *
339364 * Overview:
340365 * This test verifies that developers can customize invalidation paths specifically
341366 * for subdirectory installations using the new hooks, allowing for environment-specific
342367 * or subdirectory-specific cache invalidation strategies.
343- *
368+ *
344369 * Expected Behavior:
345370 * - Developers should be able to detect subdirectory installations in their filters
346371 * - Custom paths can be returned that are specific to the subdirectory environment
347372 * - The hooks should work correctly with both subdirectory and root installations
348- *
373+ *
349374 * Test Method:
350375 * 1. Create a filter that detects subdirectory installations and returns custom paths
351376 * 2. Test with both subdirectory and root installation scenarios
0 commit comments