Skip to content
Snippets Groups Projects
Select Git revision
  • 89330e0767424a6af5fe7dc6c384bdd651819b3a
  • master default protected
  • bugfix/wordpress-review
  • fix/duplicate
  • bugfix/get_current_screen_fail
  • feature/dismiss-nonce
  • replace-dodgy-path
  • bugfix/notice-not-show
  • devel
  • 3.3.0
  • 3.2.5
  • 3.2.4
  • 3.2.3
  • 3.2.2
  • 3.2.1
  • 3.2.0
  • 3.2.0-beta7
  • 3.2.0-beta6
  • 3.2.0-beta5
  • 3.2.0-beta4
  • 3.2.0-beta3
  • 3.2.0-beta2
  • 3.2.0-beta1
  • 3.1.4
  • 3.1.4-beta1
  • 3.1.3
  • 3.1.1
  • 3.1
  • 3.0
29 results

TestPermanentDismissinleNotice.php

Blame
  • TestPermanentDismissinleNotice.php 1.51 KiB
    <?php
    
    use \WPDesk\Notice\PermanentDismissibleNotice;
    
    class TestPermanentDismissinleNotice extends WP_UnitTestCase
    {
    
        const NOTICE_NAME = 'test_notice_name';
    
        public function testAddAction()
        {
            $notice_priority = 11;
    
            $notice = new PermanentDismissibleNotice(
                'test',
                'test_name',
                PermanentDismissibleNotice::NOTICE_TYPE_INFO,
                $notice_priority
            );
    
            $this->assertEquals($notice_priority, has_action('admin_notices', [$notice, 'showNotice'], $notice_priority));
        }
    
        public function testUndoDismiss()
        {
            update_option(
                PermanentDismissibleNotice::OPTION_NAME_PREFIX . self::NOTICE_NAME,
                PermanentDismissibleNotice::OPTION_VALUE_DISMISSED
            );
    
            $notice = new PermanentDismissibleNotice(
                PermanentDismissibleNotice::NOTICE_TYPE_INFO,
                self::NOTICE_NAME
            );
            $notice->undoDismiss();
    
            $this->assertEquals(
                '',
                get_option(PermanentDismissibleNotice::OPTION_NAME_PREFIX . self::NOTICE_NAME, '')
            );
        }
    
        public function testShowNotice()
        {
            $notice = new PermanentDismissibleNotice(
                'test',
                'test_name',
                PermanentDismissibleNotice::NOTICE_TYPE_INFO
            );
    
            $this->expectOutputString(
                '<div class="notice notice-info is-dismissible" data-notice-name="test_name" id="wpdesk-notice-test_name"><p>test</p></div>'
            );
    
            $notice->showNotice();
        }
    
    }