8000 [Bugfix] Allow resource id to be zero · khomsovon/laravel-json-api@1593f00 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1593f00

Browse files
committed
[Bugfix] Allow resource id to be zero
Closes cloudcreativity#445
1 parent 26e4355 commit 1593f00

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
All notable changes to this project will be documented in this file. This project adheres to
33
[Semantic Versioning](http://semver.org/) and [this changelog format](http://keepachangelog.com/).
44

5+
## Unreleased
6+
7+
### Fixed
8+
- [#445](https://github.com/cloudcreativity/laravel-json-api/issues/445)
9+
Allow resource identifier to be zero.
10+
511
## [1.5.0] - 2019-10-14
612

713
### Added

src/Object/IdentifiableTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public function getId()
7575
throw new RuntimeException('Id member is not a string.');
7676
}
7777

78-
if (empty($id)) {
78+
if (empty($id) && '0' !== $id) {
7979
throw new RuntimeException('Id member is an empty string.');
8080
}
8181

tests/lib/Unit/Object/ResourceIdentifierTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,4 +146,10 @@ public function testInvalidId($id)
146146
$this->expectException(RuntimeException::class);
147147
ResourceIdentifier::create('posts', $id)->getId();
148148
}
149+
150+
public function testZeroId()
151+
{
152+
$identifier = ResourceIdentifier::create('posts', '0');
153+
$this->assertSame('0', $identifier->getId());
154+
}
149155
}

0 commit comments

Comments
 (0)
0