ArticleFormTest::setUp()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 15
c 0
b 0
f 0
rs 9.7666
cc 1
nc 1
nop 0
1
<?php
2
namespace Redaxscript\Tests\Admin\View;
3
4
use Redaxscript\Admin;
5
use Redaxscript\Db;
6
use Redaxscript\Tests\TestCaseAbstract;
7
8
/**
9
 * ArticleFormTest
10
 *
11
 * @since 3.0.0
12
 *
13
 * @package Redaxscript
14
 * @category Tests
15
 * @author Henry Ruhs
16
 *
17
 * @covers Redaxscript\Admin\View\ArticleForm
18
 * @covers Redaxscript\Admin\View\ViewAbstract
19
 */
20
21
class ArticleFormTest extends TestCaseAbstract
22
{
23
	/**
24
	 * setUp
25
	 *
26
	 * @since 3.1.0
27
	 */
28
29
	public function setUp() : void
30
	{
31
		parent::setUp();
32
		$installer = $this->installerFactory();
33
		$installer->init();
34
		$installer->rawCreate();
35
		Db::forTablePrefix('articles')
36
			->create()
37
			->set(
38
			[
39
				'title' => 'Article One',
40
				'alias' => 'article-one'
41
			])
42
			->save();
43
	}
44
45
	/**
46
	 * tearDown
47
	 *
48
	 * @since 3.1.0
49
	 */
50
51
	public function tearDown() : void
52
	{
53
		$this->dropDatabase();
54
	}
55
56
	/**
57
	 * testRender
58
	 *
59
	 * @since 3.0.0
60
	 *
61
	 * @param array $registryArray
62
	 * @param int $articleId
63
	 * @param array $expectArray
64
	 *
65
	 * @dataProvider providerAutoloader
66
	 */
67
68
	public function testRender(array $registryArray = [], int $articleId = null, array $expectArray = []) : void
69
	{
70
		/* setup */
71
72
		$this->_registry->init($registryArray);
73
		$articleForm = new Admin\View\ArticleForm($this->_registry, $this->_language);
74
75
		/* actual */
76
77
		$actual = $articleForm->render($articleId);
78
79
		/* compare */
80
81
		$this->assertStringStartsWith($expectArray['start'], $actual);
82
		$this->assertStringEndsWith($expectArray['end'], $actual);
83
	}
84
}
85