Skip to content
Snippets Groups Projects
Select Git revision
  • 14c7b9b8af0bf7463038f7399c300af6b97e3214
  • master default protected
  • feat/woo-template
  • organize-tests
  • feat/add-show-rendered-method
  • devel
  • 2.1.0
  • 2.0.0
  • 1.1.0
  • 1.0.2
  • 1.0.1
  • 1.0
12 results

SimplePhpRenderer.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!'
            );
        }
    
    }