@@ -19,28 +19,28 @@ class Block_Editor_Test extends TestCase {
1919 /**
2020 * Holds the object to create the action link to duplicate.
2121 *
22- * @var Link_Builder
22+ * @var Link_Builder|Mockery\MockInterface
2323 */
2424 protected $ link_builder ;
2525
2626 /**
2727 * Holds the permissions helper.
2828 *
29- * @var Permissions_Helper
29+ * @var Permissions_Helper|Mockery\MockInterface
3030 */
3131 protected $ permissions_helper ;
3232
3333 /**
3434 * Holds the asset manager.
3535 *
36- * @var Asset_Manager
36+ * @var Asset_Manager|Mockery\MockInterface
3737 */
3838 protected $ asset_manager ;
3939
4040 /**
4141 * The instance.
4242 *
43- * @var Block_Editor
43+ * @var Block_Editor|Mockery\MockInterface
4444 */
4545 protected $ instance ;
4646
@@ -275,6 +275,14 @@ public function test_enqueue_block_editor_scripts() {
275275 'bulkactions ' => '1 ' ,
276276 ];
277277
278+ $ this ->permissions_helper
279+ ->expects ( 'is_edit_post_screen ' )
280+ ->andReturnFalse ();
281+
282+ $ this ->permissions_helper
283+ ->expects ( 'is_new_post_screen ' )
284+ ->andReturnTrue ();
285+
278286 Monkey \Functions \expect ( '\get_post ' )
279287 ->andReturn ( $ post );
280288
@@ -332,7 +340,7 @@ public function test_enqueue_block_editor_scripts() {
332340 * @runInSeparateProcess
333341 * @preserveGlobalState disabled
334342 */
335- public function test_get_new_draft_permalink_rewrite_and_republish () {
343+ public function test_get_enqueue_block_editor_scripts_rewrite_and_republish () {
336344 $ utils = Mockery::mock ( 'alias:\Yoast\WP\Duplicate_Post\Utils ' );
337345 $ post = Mockery::mock ( WP_Post::class );
338346 $ new_draft_link = 'http://fakeu.rl/new_draft ' ;
@@ -354,6 +362,10 @@ public function test_get_new_draft_permalink_rewrite_and_republish() {
354362 'bulkactions ' => '1 ' ,
355363 ];
356364
365+ $ this ->permissions_helper
366+ ->expects ( 'is_edit_post_screen ' )
367+ ->andReturnTrue ();
368+
357369 Monkey \Functions \expect ( '\get_post ' )
358370 ->andReturn ( $ post );
359371
@@ -416,25 +428,38 @@ public function test_get_new_draft_permalink_rewrite_and_republish() {
416428 *
417429 * @covers \Yoast\WP\Duplicate_Post\UI\Block_Editor::enqueue_block_editor_scripts
418430 */
419- public function test_get_new_draft_permalink_no_post () {
431+ public function test_enqueue_block_editor_scripts_no_post () {
432+ $ this ->permissions_helper
433+ ->expects ( 'is_edit_post_screen ' )
434+ ->andReturnTrue ();
435+
420436 Monkey \Functions \expect ( '\get_post ' )
421437 ->andReturnNull ();
422438
423- $ this ->permissions_helper
424- ->expects ( 'is_rewrite_and_republish_copy ' )
439+ $ this ->asset_manager
440+ ->expects ( 'enqueue_edit_script ' )
425441 ->never ();
426442
427- $ this ->instance
428- ->expects ( 'get_new_draft_permalink ' )
443+ $ this ->asset_manager
444+ ->expects ( 'enqueue_strings_script ' )
429445 ->never ();
430446
431- $ this ->instance
432- ->expects ( 'get_rewrite_republish_permalink ' )
433- ->never ();
447+ $ this ->instance ->enqueue_block_editor_scripts ();
448+ }
434449
435- $ this ->instance
436- ->expects ( 'get_original_post_edit_url ' )
437- ->never ();
450+ /**
451+ * Tests the enqueueing of the scripts when no post is displayed.
452+ *
453+ * @covers \Yoast\WP\Duplicate_Post\UI\Block_Editor::enqueue_block_editor_scripts
454+ */
455+ public function test_enqueue_block_editor_scripts_not_editor () {
456+ $ this ->permissions_helper
457+ ->expects ( 'is_edit_post_screen ' )
458+ ->andReturnFalse ();
459+
460+ $ this ->permissions_helper
461+ ->expects ( 'is_new_post_screen ' )
462+ ->andReturnFalse ();
438463
439464 $ this ->asset_manager
440465 ->expects ( 'enqueue_edit_script ' )
@@ -444,10 +469,6 @@ public function test_get_new_draft_permalink_no_post() {
444469 ->expects ( 'enqueue_strings_script ' )
445470 ->never ();
446471
447- $ this ->instance
448- ->expects ( 'get_check_permalink ' )
449- ->never ();
450-
451472 $ this ->instance ->enqueue_block_editor_scripts ();
452473 }
453474
0 commit comments