Skip to content
Snippets Groups Projects
Select Git revision
  • 0e17e2a498cae04861bca30312348505b4f4e258
  • master default protected
  • feat/npm-publish
  • feat/demo-deploy
  • change-demo-deploy
  • remove-smoke
  • feat/acceptance-tests
  • feature/deploy-composer.json
  • feature/mysql-bin-logs
  • skip-codecept-for-libs
  • include-composer-json
  • exclude-wp-assets
  • update_codecept_image
  • fix/silenced-copy
  • remove-free-translations
  • codeception-with-optional-step
  • improve-parallelization
  • linter-exit
  • change-images
  • fix/linter
  • globally-raise-mem-limit
  • no-symlink2
22 results

unit.yml

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();
        }
    
    }