Completed
Push — master ( 16ddfb...0ea243 )
by Henry
09:18
created

tests/unit/Model/CommentTest.php (2 issues)

calls to non-existent methods.

Bug Major

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
namespace Redaxscript\Tests\Model;
3
4
use Redaxscript\Db;
5
use Redaxscript\Model;
6
use Redaxscript\Tests\TestCaseAbstract;
7
8
/**
9
 * CommentTest
10
 *
11
 * @since 4.0.0
12
 *
13
 * @package Redaxscript
14
 * @category Tests
15
 * @author Henry Ruhs
16
 *
17
 * @covers Redaxscript\Model\Comment
18
 */
19
20
class CommentTest extends TestCaseAbstract
21
{
22
	/**
23
	 * setUp
24
	 *
25
	 * @since 4.0.0
26
	 */
27
28
	public function setUp() : void
29
	{
30
		parent::setUp();
31
		$optionArray =
32
		[
33
			'adminName' => 'Test',
34
			'adminUser' => 'test',
35
			'adminPassword' => 'test',
36
			'adminEmail' => '[email protected]'
37
		];
38
		$installer = $this->installerFactory();
0 ignored issues
show
The method installerFactory() does not seem to exist on object<Redaxscript\Tests\Model\CommentTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
39
		$installer->init();
40
		$installer->rawCreate();
41
		$installer->insertSettings($optionArray);
42
		$categoryOne = Db::forTablePrefix('categories')->create();
43
		$categoryOne
44
			->set(
45
			[
46
				'title' => 'Category One',
47
				'alias' => 'category-one'
48
			])
49
			->save();
50
		$categoryTwo = Db::forTablePrefix('categories')->create();
51
		$categoryTwo
52
			->set(
53
			[
54
				'title' => 'Category Two',
55
				'alias' => 'category-two',
56
				'parent' => $categoryOne->id
57
			])
58
			->save();
59
		$articleOne = Db::forTablePrefix('articles')->create();
60
		$articleOne
61
			->set(
62
			[
63
				'title' => 'Article One',
64
				'alias' => 'article-one',
65
				'category' => $categoryOne->id
66
			])
67
			->save();
68
		$articleTwo = Db::forTablePrefix('articles')->create();
69
		$articleTwo
70
			->set(
71
			[
72
				'title' => 'Article Two',
73
				'alias' => 'article-two',
74
				'category' => $categoryTwo->id
75
			])
76
			->save();
77
		$articleThree = Db::forTablePrefix('articles')->create();
78
		$articleThree
79
			->set(
80
			[
81
				'title' => 'Article Three',
82
				'alias' => 'article-three'
83
			])
84
			->save();
85
		Db::forTablePrefix('comments')
86
			->create()
87
			->set(
88
			[
89
				'author' => 'Comment One',
90
				'text' => 'Comment One',
91
				'article' => $articleOne->id
92
			])
93
			->save();
94
		Db::forTablePrefix('comments')
95
			->create()
96
			->set(
97
			[
98
				'author' => 'Comment Two',
99
				'text' => 'Comment Two',
100
				'article' => $articleTwo->id
101
			])
102
			->save();
103
		Db::forTablePrefix('comments')
104
			->create()
105
			->set(
106
			[
107
				'author' => 'Comment Three',
108
				'text' => 'Comment Three',
109
				'article' => $articleThree->id
110
			])
111
			->save();
112
	}
113
114
	/**
115
	 * tearDown
116
	 *
117
	 * @since 4.0.0
118
	 */
119
120
	public function tearDown() : void
121
	{
122
		$this->dropDatabase();
0 ignored issues
show
The method dropDatabase() does not seem to exist on object<Redaxscript\Tests\Model\CommentTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
123
	}
124
125
	/**
126
	 * testGetRouteById
127
	 *
128
	 * @since 4.0.0
129
	 *
130
	 * @param int $commentId
131
	 * @param string $expect
132
	 *
133
	 * @dataProvider providerAutoloader
134
	 */
135
136
	public function testGetRouteById(int $commentId = null, string $expect = null) : void
137
	{
138
		/* setup */
139
140
		$commentModel = new Model\Comment();
141
142
		/* actual */
143
144
		$actual = $commentModel->getRouteById($commentId);
145
146
		/* compare */
147
148
		$this->assertEquals($expect, $actual);
149
	}
150
}
151