-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathTestCase.php
65 lines (55 loc) · 1.54 KB
/
TestCase.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php declare(strict_types=1);
namespace Tkui\Tests;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\MockObject\Stub;
use PHPUnit\Framework\TestCase as FrameworkTestCase;
use Tkui\Application;
use Tkui\Evaluator;
use Tkui\Windows\Window;
class TestCase extends FrameworkTestCase
{
protected $app;
protected $eval;
protected function setUp(): void
{
parent::setUp();
$this->app = $this->createAppMock();
$this->eval = $this->createEvalMock();
$this->emptyEval();
}
/**
* @return Application|MockObject
*/
protected function createAppMock()
{
return $this->createMock(Application::class);
}
protected function createEvalMock()
{
return $this->createMock(Evaluator::class);
}
protected function createWindowStub(): Window
{
/** @var Window|Stub $win */
$win = $this->createStub(Window::class);
$win->method('getEval')->willReturn($this->eval);
$win->method('path')->willReturn('.');
$win->method('window')->willReturnSelf();
return $win;
}
protected function checkWidget(string $name)
{
return $this->stringStartsWith($name);
}
protected function tclEvalTest(int $count, $args)
{
return $this->eval
->expects($this->exactly($count))
->method('tclEval')
->withConsecutive(...$args)->willReturn('');
}
protected function emptyEval()
{
$this->eval->method('tclEval')->willReturn('');
}
}