• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

daycry / auth / 22527658769

28 Feb 2026 07:41PM UTC coverage: 63.267% (-3.6%) from 66.864%
22527658769

push

github

web-flow
Merge pull request #36 from daycry/development

Implement TOTP 2FA, JWT auth, device session tracking, and docs overhaul

465 of 1168 new or added lines in 52 files covered. (39.81%)

129 existing lines in 46 files now uncovered.

3064 of 4843 relevant lines covered (63.27%)

41.53 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

79.41
/src/Test/MockInputOutput.php
1
<?php
2

3
declare(strict_types=1);
4

5
/**
6
 * This file is part of Daycry Auth.
7
 *
8
 * (c) Daycry <daycry9@proton.me>
9
 *
10
 * For the full copyright and license information, please view
11
 * the LICENSE file that was distributed with this source code.
12
 */
13

14
namespace Daycry\Auth\Test;
15

16
use CodeIgniter\CLI\CLI;
17
use CodeIgniter\Test\Filters\CITestStreamFilter;
18
use CodeIgniter\Test\PhpStreamWrapper;
19
use Daycry\Auth\Commands\Utils\InputOutput;
20
use Daycry\Exceptions\Exceptions\LogicException;
21

22
final class MockInputOutput extends InputOutput
23
{
24
    private array $inputs  = [];
25
    private array $outputs = [];
26

27
    /**
28
     * Sets user inputs.
29
     */
30
    public function setInputs(array $inputs): void
24✔
31
    {
32
        $this->inputs = $inputs;
24✔
33
    }
34

35
    /**
36
     * Takes the last output from the output array.
37
     */
38
    public function getLastOutput(): string
15✔
39
    {
40
        return array_pop($this->outputs);
15✔
41
    }
42

43
    /**
44
     * Takes the first output from the output array.
45
     */
46
    public function getFirstOutput(): string
5✔
47
    {
48
        return array_shift($this->outputs);
5✔
49
    }
50

51
    /**
52
     * Returns all outputs.
53
     */
54
    public function getOutputs(): string
4✔
55
    {
56
        return implode('', $this->outputs);
4✔
57
    }
58

59
    public function prompt(string $field, $options = null, $validation = null, ?string $DBGroup = null): string
16✔
60
    {
61
        $input = array_shift($this->inputs);
16✔
62

63
        CITestStreamFilter::registration();
16✔
64
        CITestStreamFilter::addOutputFilter();
16✔
65
        CITestStreamFilter::addErrorFilter();
16✔
66

67
        PhpStreamWrapper::register();
16✔
68
        PhpStreamWrapper::setContent($input);
16✔
69

70
        $userInput = CLI::prompt($field, $options, $validation);
16✔
71

72
        PhpStreamWrapper::restore();
16✔
73

74
        CITestStreamFilter::removeOutputFilter();
16✔
75
        CITestStreamFilter::removeErrorFilter();
16✔
76

77
        if ($input !== $userInput) {
16✔
78
            throw new LogicException($input . '!==' . $userInput);
×
79
        }
80

81
        return $input;
16✔
82
    }
83

84
    public function write(
24✔
85
        string $text = '',
86
        ?string $foreground = null,
87
        ?string $background = null,
88
    ): void {
89
        CITestStreamFilter::registration();
24✔
90
        CITestStreamFilter::addOutputFilter();
24✔
91

92
        CLI::write($text, $foreground, $background);
24✔
93
        $this->outputs[] = CITestStreamFilter::$buffer;
24✔
94

95
        CITestStreamFilter::removeOutputFilter();
24✔
96
    }
97

UNCOV
98
    public function error(string $text, string $foreground = 'light_red', ?string $background = null): void
×
99
    {
100
        CITestStreamFilter::registration();
×
101
        CITestStreamFilter::addErrorFilter();
×
102

103
        CLI::error($text, $foreground, $background);
×
104
        $this->outputs[] = CITestStreamFilter::$buffer;
×
105

106
        CITestStreamFilter::removeErrorFilter();
×
107
    }
108
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc