Skip to content

Commit 6428953

Browse files
committed
fix validation
1 parent eb6fdce commit 6428953

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/Service/Taxonomy/Validator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function assert(Taxonomy $taxonomy, ?string $tenantId, ?Table\Generated\T
6060

6161
private function assertParentId(int $parentId, ?string $tenantId, ?Table\Generated\TaxonomyRow $existing = null): void
6262
{
63-
$row = $this->taxonomyTable->findOneByTenantAndId($parentId, $tenantId);
63+
$row = $this->taxonomyTable->findOneByTenantAndId($tenantId, $parentId);
6464
if (!$row instanceof TaxonomyRow) {
6565
throw new StatusCode\BadRequestException('Parent taxonomy does not exist');
6666
}

tests/Backend/Api/Taxonomy/CollectionTest.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,8 @@ public function testPost()
141141
'User-Agent' => 'Fusio TestCase',
142142
'Authorization' => 'Bearer da250526d583edabca8ac2f99e37ee39aa02a3c076c0edc6929095e20ca18dcf'
143143
), json_encode([
144-
'name' => 'developer',
144+
'parentId' => 2,
145+
'name' => 'feature_a_a_a',
145146
]));
146147

147148
$body = (string) $response->getBody();
@@ -158,7 +159,7 @@ public function testPost()
158159

159160
// check database
160161
$sql = $this->connection->createQueryBuilder()
161-
->select('id', 'status', 'name')
162+
->select('id', 'parent_id', 'status', 'name')
162163
->from('fusio_taxonomy')
163164
->orderBy('id', 'DESC')
164165
->setFirstResult(0)
@@ -168,7 +169,8 @@ public function testPost()
168169
$row = $this->connection->fetchAssociative($sql);
169170

170171
$this->assertEquals(1, $row['status']);
171-
$this->assertEquals('developer', $row['name']);
172+
$this->assertEquals(2, $row['parent_id']);
173+
$this->assertEquals('feature_a_a_a', $row['name']);
172174
}
173175

174176
public function testPut()

0 commit comments

Comments
 (0)