HEX
Server: Apache/2.4.41 (Ubuntu)
System: Linux ip-172-31-42-149 5.15.0-1084-aws #91~20.04.1-Ubuntu SMP Fri May 2 07:00:04 UTC 2025 aarch64
User: ubuntu (1000)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/vhost/disk-apps/magento.bikenow.co/vendor/hoa/console/Test/Unit/Tput.php
<?php

/**
 * Hoa
 *
 *
 * @license
 *
 * New BSD License
 *
 * Copyright © 2007-2017, Hoa community. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *     * Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above copyright
 *       notice, this list of conditions and the following disclaimer in the
 *       documentation and/or other materials provided with the distribution.
 *     * Neither the name of the Hoa nor the names of its contributors may be
 *       used to endorse or promote products derived from this software without
 *       specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */

namespace Hoa\Console\Test\Unit;

use Hoa\Console\Tput as SUT;
use Hoa\Test;

/**
 * Class \Hoa\Console\Test\Unit\Tput.
 *
 * Test suite of the tput parser.
 *
 * @copyright  Copyright © 2007-2017 Hoa community
 * @license    New BSD License
 */
class Tput extends Test\Unit\Suite
{
    public function case_get_term_from_environment()
    {
        $this
            ->given($_SERVER['TERM'] = 'foo')
            ->when($result = SUT::getTerm())
            ->then
                ->string($result)
                    ->isEqualTo('foo');
    }

    public function case_get_unknown_term_on_windows()
    {
        unset($_SERVER['TERM']);

        $this
            ->given($this->constant->OS_WIN = true)
            ->when($result = SUT::getTerm())
            ->then
                ->string($result)
                    ->isEqualTo('windows-ansi');
    }

    public function case_get_unknown_term()
    {
        unset($_SERVER['TERM']);

        $this
            ->given($this->constant->OS_WIN = false)
            ->when($result = SUT::getTerm())
            ->then
                ->string($result)
                    ->isEqualTo('xterm');
    }

    public function case_unknown_file_when_parsing()
    {
        $this
            ->exception(function () {
                new SUT('/hoa/flatland');
            })
                ->isInstanceOf('Hoa\Console\Exception');
    }

    public function case_all_informations()
    {
        $this
            ->given($tput = new SUT('hoa://Library/Console/Terminfo/78/xterm'))
            ->when($result = $tput->getInformations())
            ->then
                ->array($result)
                    ->isIdenticalTo([
                        'file'    => 'hoa://Library/Console/Terminfo/78/xterm',
                        'headers' => [
                            'data_size'         => 3258,
                            'header_size'       => 12,
                            'magic_number'      => 282,
                            'names_size'        => 48,
                            'bool_count'        => 38,
                            'number_count'      => 15,
                            'string_count'      => 413,
                            'string_table_size' => 1388
                        ],
                        'name'        => 'xterm',
                        'description' => 'xterm terminal emulator (X Window System)',
                        'booleans'    => [
                            'auto_left_margin'         => false,
                            'auto_right_margin'        => true,
                            'no_esc_ctlc'              => false,
                            'ceol_standout_glitch'     => false,
                            'eat_newline_glitch'       => true,
                            'erase_overstrike'         => false,
                            'generic_type'             => false,
                            'hard_copy'                => false,
                            'meta_key'                 => true,
                            'status_line'              => false,
                            'insert_null_glitch'       => false,
                            'memory_above'             => false,
                            'memory_below'             => false,
                            'move_insert_mode'         => true,
                            'move_standout_mode'       => true,
                            'over_strike'              => false,
                            'status_line_esc_ok'       => false,
                            'dest_tabs_magic_smso'     => false,
                            'tilde_glitch'             => false,
                            'transparent_underline'    => false,
                            'xon_xoff'                 => false,
                            'needs_xon_xoff'           => false,
                            'prtr_silent'              => true,
                            'hard_cursor'              => false,
                            'non_rev_rmcup'            => false,
                            'no_pad_char'              => true,
                            'non_dest_scroll_region'   => false,
                            'can_change'               => false,
                            'back_color_erase'         => true,
                            'hue_lightness_saturation' => false,
                            'col_addr_glitch'          => false,
                            'cr_cancels_micro_mode'    => false,
                            'print_wheel'              => false,
                            'row_addr_glitch'          => false,
                            'semi_auto_right_margin'   => false,
                            'cpi_changes_res'          => false,
                            'lpi_changes_res'          => false,
                            'backspaces_with_bs'       => true
                        ],
                        'numbers' => [
                            'columns'             => 80,
                            'init_tabs'           => 8,
                            'lines'               => 24,
                            'lines_of_memory'     => -1,
                            'magic_cookie_glitch' => -1,
                            'padding_baud_rate'   => -1,
                            'virtual_terminal'    => -1,
                            'width_status_line'   => -1,
                            'num_labels'          => -1,
                            'label_height'        => -1,
                            'label_width'         => -1,
                            'max_attributes'      => -1,
                            'maximum_windows'     => -1,
                            'max_colors'          => 8,
                            'max_pairs'           => 64
                        ],
                        'strings' => [
                            'back_tab'               => '',
                            'bell'                   => '',
                            'carriage_return'        => '
',
                            'change_scroll_region'   => '[%i%p1%d;%p2%dr',
                            'clear_all_tabs'         => '',
                            'clear_screen'           => '',
                            'clr_eol'                => '',
                            'clr_eos'                => '',
                            'column_address'         => '[%i%p1%dG',
                            'cursor_address'         => '[%i%p1%d;%p2%dH',
                            'cursor_down'            => "\n",
                            'cursor_home'            => '',
                            'cursor_invisible'       => '[?25l',
                            'cursor_left'            => '',
                            'cursor_normal'          => '[?12l[?25h',
                            'cursor_right'           => '',
                            'cursor_up'              => '',
                            'cursor_visible'         => '[?12;25h',
                            'delete_character'       => '',
                            'delete_line'            => '',
                            'enter_alt_charset_mode' => '(0',
                            'enter_blink_mode'       => '',
                            'enter_bold_mode'        => '',
                            'enter_ca_mode'          => '[?1049h',
                            'enter_insert_mode'      => '',
                            'enter_secure_mode'      => '',
                            'enter_reverse_mode'     => '',
                            'enter_standout_mode'    => '',
                            'enter_underline_mode'   => '',
                            'erase_chars'            => '[%p1%dX',
                            'exit_alt_charset_mode'  => '(B',
                            'exit_attribute_mode'    => '(B',
                            'exit_ca_mode'           => '[?1049l',
                            'exit_insert_mode'       => '',
                            'exit_standout_mode'     => '',
                            'exit_underline_mode'    => '',
                            'flash_screen'           => '[?5h$<100/>[?5l',
                            'init_2string'           => '[!p[?3;4l>',
                            'insert_line'            => '',
                            'key_backspace'          => '',
                            'key_dc'                 => '[3~',
                            'key_down'               => 'OB',
                            'key_f1'                 => 'OP',
                            'key_f10'                => '[21~',
                            'key_f2'                 => 'OQ',
                            'key_f3'                 => 'OR',
                            'key_f4'                 => 'OS',
                            'key_f5'                 => '[15~',
                            'key_f6'                 => '[17~',
                            'key_f7'                 => '[18~',
                            'key_f8'                 => '[19~',
                            'key_f9'                 => '[20~',
                            'key_home'               => 'OH',
                            'key_ic'                 => '[2~',
                            'key_left'               => 'OD',
                            'key_npage'              => '[6~',
                            'key_ppage'              => '[5~',
                            'key_right'              => 'OC',
                            'key_sf'                 => '',
                            'key_sr'                 => '',
                            'key_up'                 => 'OA',
                            'keypad_local'           => '[?1l>',
                            'keypad_xmit'            => '[?1h=',
                            'meta_off'               => '[?1034l',
                            'meta_on'                => '[?1034h',
                            'parm_dch'               => '[%p1%dP',
                            'parm_delete_line'       => '[%p1%dM',
                            'parm_down_cursor'       => '[%p1%dB',
                            'parm_ich'               => '[%p1%d@',
                            'parm_index'             => '[%p1%dS',
                            'parm_insert_line'       => '[%p1%dL',
                            'parm_left_cursor'       => '[%p1%dD',
                            'parm_right_cursor'      => '[%p1%dC',
                            'parm_rindex'            => '[%p1%dT',
                            'parm_up_cursor'         => '[%p1%dA',
                            'print_screen'           => '',
                            'prtr_off'               => '',
                            'prtr_on'                => '',
                            'reset_1string'          => 'c',
                            'reset_2string'          => '[!p[?3;4l>',
                            'restore_cursor'         => '8',
                            'row_address'            => '[%i%p1%dd',
                            'save_cursor'            => '7',
                            'scroll_forward'         => "\n",
                            'scroll_reverse'         => 'M',
                            'set_attributes'         => '%?%p9%t(0%e(B%;[0%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;%?%p7%t;8%;m',
                            'set_tab'                => 'H',
                            'tab'                    => '	',
                            'key_b2'                 => 'OE',
                            'acs_chars'              => '``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~',
                            'key_btab'               => '',
                            'enter_am_mode'          => '[?7h',
                            'exit_am_mode'           => '[?7l',
                            'key_end'                => 'OF',
                            'key_enter'              => 'OM',
                            'key_sdc'                => '[3;2~',
                            'key_send'               => '',
                            'key_shome'              => '',
                            'key_sic'                => '[2;2~',
                            'key_sleft'              => '',
                            'key_snext'              => '[6;2~',
                            'key_sprevious'          => '[5;2~',
                            'key_sright'             => '',
                            'key_f11'                => '[23~',
                            'key_f12'                => '[24~',
                            'key_f13'                => '',
                            'key_f14'                => '',
                            'key_f15'                => '',
                            'key_f16'                => '',
                            'key_f17'                => '[15;2~',
                            'key_f18'                => '[17;2~',
                            'key_f19'                => '[18;2~',
                            'key_f20'                => '[19;2~',
                            'key_f21'                => '[20;2~',
                            'key_f22'                => '[21;2~',
                            'key_f23'                => '[23;2~',
                            'key_f24'                => '[24;2~',
                            'key_f25'                => '',
                            'key_f26'                => '',
                            'key_f27'                => '',
                            'key_f28'                => '',
                            'key_f29'                => '[15;5~',
                            'key_f30'                => '[17;5~',
                            'key_f31'                => '[18;5~',
                            'key_f32'                => '[19;5~',
                            'key_f33'                => '[20;5~',
                            'key_f34'                => '[21;5~',
                            'key_f35'                => '[23;5~',
                            'key_f36'                => '[24;5~',
                            'key_f37'                => '',
                            'key_f38'                => '',
                            'key_f39'                => '',
                            'key_f40'                => '',
                            'key_f41'                => '[15;6~',
                            'key_f42'                => '[17;6~',
                            'key_f43'                => '[18;6~',
                            'key_f44'                => '[19;6~',
                            'key_f45'                => '[20;6~',
                            'key_f46'                => '[21;6~',
                            'key_f47'                => '[23;6~',
                            'key_f48'                => '[24;6~',
                            'key_f49'                => '',
                            'key_f50'                => '',
                            'key_f51'                => '',
                            'key_f52'                => '',
                            'key_f53'                => '[15;3~',
                            'key_f54'                => '[17;3~',
                            'key_f55'                => '[18;3~',
                            'key_f56'                => '[19;3~',
                            'key_f57'                => '[20;3~',
                            'key_f58'                => '[21;3~',
                            'key_f59'                => '[23;3~',
                            'key_f60'                => '[24;3~',
                            'key_f61'                => '',
                            'key_f62'                => '',
                            'key_f63'                => '',
                            'clr_bol'                => '',
                            'user6'                  => '[%i%d;%dR',
                            'user7'                  => '',
                            'user8'                  => '[?1;2c',
                            'user9'                  => '',
                            'orig_pair'              => '',
                            'set_foreground'         => '[3%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}%=%t3%e%p1%d%;m',
                            'set_background'         => '[4%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}%=%t3%e%p1%d%;m',
                            'key_mouse'              => '',
                            'set_a_foreground'       => '[3%p1%dm',
                            'set_a_background'       => '[4%p1%dm',
                            'memory_lock'            => 'l',
                            'memory_unlock'          => 'm'
                        ]
                    ]);
    }

    public function case_has()
    {
        $this
            ->given($tput = new SUT('hoa://Library/Console/Terminfo/78/xterm'))
            ->when($result = $tput->has('auto_left_margin'))
            ->then
                ->boolean($result)
                    ->isFalse()

            ->when($result = $tput->has('auto_right_margin'))
                ->then
                ->boolean($result)
                    ->isTrue();
    }

    public function case_has_unknown_boolean()
    {
        $this
            ->given($tput = new SUT('hoa://Library/Console/Terminfo/78/xterm'))
            ->when($result = $tput->has('💩'))
            ->then
                ->boolean($result)
                    ->isFalse();
    }

    public function case_count()
    {
        $this
            ->given($tput = new SUT('hoa://Library/Console/Terminfo/78/xterm'))
            ->when($result = $tput->count('columns'))
            ->then
                ->integer($result)
                    ->isEqualTo(80);
    }

    public function case_count_unknown_integer()
    {
        $this
            ->given($tput = new SUT('hoa://Library/Console/Terminfo/78/xterm'))
            ->when($result = $tput->count('💩'))
            ->then
                ->integer($result)
                    ->isEqualTo(0);
    }

    public function case_get()
    {
        $this
            ->given($tput = new SUT('hoa://Library/Console/Terminfo/78/xterm'))
            ->when($result = $tput->get('cursor_down'))
            ->then
                ->string($result)
                    ->isEqualTo("\n");
    }

    public function case_get_unknown_string()
    {
        $this
            ->given($tput = new SUT('hoa://Library/Console/Terminfo/78/xterm'))
            ->when($result = $tput->get('💩'))
            ->then
                ->variable($result)
                    ->isNull();
    }
}