Skip to content
Snippets Groups Projects
Select Git revision
  • 62141b57f8db9b947090319c620092714f1b15f8
  • master default protected
  • bugfix/wordpress-review
  • bugfix/prevent-error-notice
  • remove-arrow
  • feature/update-message
  • feature/minimum-plugin-version-check-demo1
  • feature/plugin-name
  • 3.7.1
  • 3.7.0
  • 3.6.3
  • 3.6.2
  • 3.6.1
  • 3.6.0
  • 3.6.0-beta3
  • 3.6.0-beta2
  • 3.6.0-beta1
  • 3.5.2
  • 3.5.1
  • 3.5.0
  • 3.4.0
  • 3.3.0
  • 3.2.8
  • 3.2.7
  • 3.2.6
  • 3.2.5
  • 3.2.4
  • 3.2.3
28 results

Basic_Requirement_Checker_Factory.php

Blame
  • TestAjaxHandler.php 1.16 KiB
    <?php
    
    use \WPDesk\Notice\AjaxHandler;
    
    class TestAjaxHandler extends WP_UnitTestCase
    {
    
        const ASSETS_URL = 'http://test.com/test/assetes/';
        const WP_DEFAULT_PRIORITY = 10;
    
        public function testHooks()
        {
            $ajaxHandler = new AjaxHandler(self::ASSETS_URL);
            $ajaxHandler->hooks();
    
            $this->assertEquals(
                self::WP_DEFAULT_PRIORITY,
                has_action('admin_enqueue_scripts', [$ajaxHandler, 'enqueueAdminScripts'])
            );
            $this->assertEquals(
                self::WP_DEFAULT_PRIORITY,
                has_action('wp_ajax_wpdesk_notice_dismiss', [$ajaxHandler, 'processAjaxNoticeDismiss'])
            );
        }
    
        public function testEnqueueAdminScripts()
        {
            $ajaxHandler = new AjaxHandler(self::ASSETS_URL);
            $ajaxHandler->hooks();
            do_action('admin_enqueue_scripts');
            $registeredScripts = wp_scripts()->registered;
    
            $this->assertArrayHasKey('wpdesk_notice', $registeredScripts, 'Script not registered!');
            $this->assertEquals(
                self::ASSETS_URL . 'js/notice.js',
                $registeredScripts['wpdesk_notice']->src,
                'Script src is invalid!'
            );
        }
    
    }