Skip to content

Commit

Permalink
revert stringFormatter: revert 'smart' bool to string conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
misha-rollun committed Jan 28, 2022
1 parent aba0091 commit 6a987e9
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 14 deletions.
6 changes: 0 additions & 6 deletions src/DataStore/src/DataStore/Type/TypeString.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,6 @@ public function toTypeValue()
}

try {
if ($this->value === true) {
return 'true';
}
if ($this->value === false) {
return 'false';
}
if (is_array($this->value)) {
return json_encode($this->value);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ public function dataProvider(): array
'Convert string' => [$str = uniqid(), $str],
'Convert int' => [123, '123'],
'Convert float' => [12.345, '12.345'],
'Convert bool false' => [false, 'false'],
'Convert bool true' => [true, 'true'],
'Convert bool false' => [false, ''],
'Convert bool true' => [true, '1'],
'Convert associative array' => [['key' => 'value'], '{"key":"value"}'],
'Convert list array' => [['str', 123, 1.23], '["str",123,1.23]']
];
Expand Down
7 changes: 1 addition & 6 deletions test/unit/DataStore/DataStore/Type/TypeStringTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public function testToTypeValueSuccess()
$this->assertSame('1', $this->createObject(true)->toTypeValue());
$this->assertSame('', $this->createObject(false)->toTypeValue());
$this->assertSame('', $this->createObject(null)->toTypeValue());
$this->assertSame('[]', $this->createObject([])->toTypeValue());
}

public function testToTypeValueFailWithObject()
Expand All @@ -48,12 +49,6 @@ public function testToTypeValueFailWithCallable()
})->toTypeValue();
}

public function testToTypeValueFailWithArray()
{
$this->expectException(TypeException::class);
$this->createObject([])->toTypeValue();
}

public function testToTypeValueFailWithResource()
{
$this->expectException(TypeException::class);
Expand Down

0 comments on commit 6a987e9

Please sign in to comment.