Skip to content

Commit 9c49b24

Browse files
authored
Modifies tests to acknowledge Ticket API changes in #2421 (#44)
1 parent 83f0129 commit 9c49b24

File tree

1 file changed

+30
-7
lines changed

1 file changed

+30
-7
lines changed

test/ZammadAPIClient/Resource/TicketTest.php

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ public function objectCreateProvider()
2525
'body' => 'Unit test article 1... ' . $this->getUniqueID(),
2626
],
2727
],
28-
'expected_success' => true,
28+
'expected_success' => true,
29+
'expected_article_count' => 1,
2930
],
3031
// Another object with valid data.
3132
[
@@ -40,7 +41,23 @@ public function objectCreateProvider()
4041
'body' => 'Unit test article 2... ' . $this->getUniqueID(),
4142
],
4243
],
43-
'expected_success' => true,
44+
'expected_success' => true,
45+
'expected_article_count' => 1,
46+
],
47+
// Missing required field 'body'.
48+
[
49+
'values' => [
50+
'group_id' => 1,
51+
'priority_id' => 1,
52+
'state_id' => 1,
53+
'title' => 'Unit test ticket 2 ' . $this->getUniqueID(),
54+
'customer_id' => 1,
55+
'article' => [
56+
'subject' => 'Unit test article 2 ' . $this->getUniqueID(),
57+
'body' => '',
58+
],
59+
],
60+
'expected_success' => false,
4461
],
4562
// Missing required field 'group_id'.
4663
[
@@ -57,7 +74,7 @@ public function objectCreateProvider()
5774
],
5875
'expected_success' => false,
5976
],
60-
// Missing article data.
77+
// Allows to create a stub ticket without an article.
6178
[
6279
'values' => [
6380
'group_id' => 1,
@@ -70,7 +87,8 @@ public function objectCreateProvider()
7087
// 'body' => 'Unit test article 6... ' . $this->getUniqueID(),
7188
// ],
7289
],
73-
'expected_success' => false,
90+
'expected_success' => true,
91+
'expected_article_count' => 0,
7492
],
7593
];
7694

@@ -80,7 +98,7 @@ public function objectCreateProvider()
8098
/**
8199
* @dataProvider objectCreateProvider
82100
*/
83-
public function testCreate( $values, $expected_success )
101+
public function testCreate( $values, $expected_success, $expected_article_count = 0 )
84102
{
85103
$object = self::getClient()->resource( $this->resource_type );
86104
$this->assertInstanceOf(
@@ -176,12 +194,17 @@ public function testCreate( $values, $expected_success )
176194
$articles,
177195
'Articles of ticket object must be returned as array.'
178196
);
197+
179198
$this->assertCount(
180-
1,
199+
$expected_article_count,
181200
$articles,
182-
'Ticket object must have exactly one article.'
201+
'Ticket object must have exactly '.$expected_article_count.' article(s).'
183202
);
184203

204+
if (!$expected_article_count) {
205+
return;
206+
}
207+
185208
$article = array_shift($articles);
186209
foreach ( $values['article'] as $field => $expected_value ) {
187210

0 commit comments

Comments
 (0)