-
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implement the interface ArrayableInterface for BaseActiveRecord
- Loading branch information
1 parent
3988dcc
commit 424f841
Showing
5 changed files
with
137 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -771,7 +771,16 @@ public function testToArrayForArrayable(): void | |
$this->checkFixture($this->db, 'customer', true); | ||
|
||
$customerQuery = new ActiveQuery(CustomerForArrayable::class, $this->db); | ||
|
||
/** @var CustomerForArrayable $customer */ | ||
$customer = $customerQuery->findOne(1); | ||
/** @var CustomerForArrayable $customer2 */ | ||
$customer2 = $customerQuery->findOne(2); | ||
/** @var CustomerForArrayable $customer3 */ | ||
$customer3 = $customerQuery->findOne(3); | ||
|
||
$customer->setItem($customer2); | ||
$customer->setItems($customer3); | ||
|
||
$this->assertSame( | ||
[ | ||
|
@@ -780,9 +789,34 @@ public function testToArrayForArrayable(): void | |
'name' => 'user1', | ||
'address' => 'address1', | ||
'status' => 'active', | ||
'profile_id' => 1, | ||
'item' => [ | ||
'id' => 2, | ||
'name' => 'user2', | ||
'email' => '[email protected]', | ||
'status' => 'active', | ||
], | ||
'items' => [ | ||
[ | ||
'id' => 3, | ||
'email' => '[email protected]', | ||
'name' => 'user3', | ||
'status' => 'inactive', | ||
], | ||
] | ||
], | ||
ArrayHelper::toArray($customer), | ||
$customer->toArray([ | ||
'id', | ||
'name', | ||
'email', | ||
'address', | ||
'status', | ||
'item.id', | ||
'item.name', | ||
'item.email', | ||
'items.0.id', | ||
'items.0.name', | ||
'items.0.email', | ||
]), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -174,7 +174,16 @@ public function testToArrayForArrayable(): void | |
$this->checkFixture($this->db, 'customer', true); | ||
|
||
$customerQuery = new ActiveQuery(CustomerForArrayable::class, $this->db); | ||
|
||
/** @var CustomerForArrayable $customer */ | ||
$customer = $customerQuery->findOne(1); | ||
/** @var CustomerForArrayable $customer2 */ | ||
$customer2 = $customerQuery->findOne(2); | ||
/** @var CustomerForArrayable $customer3 */ | ||
$customer3 = $customerQuery->findOne(3); | ||
|
||
$customer->setItem($customer2); | ||
$customer->setItems($customer3); | ||
|
||
$this->assertSame( | ||
[ | ||
|
@@ -183,10 +192,34 @@ public function testToArrayForArrayable(): void | |
'name' => 'user1', | ||
'address' => 'address1', | ||
'status' => 'active', | ||
'bool_status' => '1', | ||
'profile_id' => 1, | ||
'item' => [ | ||
'id' => 2, | ||
'name' => 'user2', | ||
'email' => '[email protected]', | ||
'status' => 'active', | ||
], | ||
'items' => [ | ||
[ | ||
'id' => 3, | ||
'email' => '[email protected]', | ||
'name' => 'user3', | ||
'status' => 'inactive', | ||
], | ||
] | ||
], | ||
ArrayHelper::toArray($customer), | ||
$customer->toArray([ | ||
'id', | ||
'name', | ||
'email', | ||
'address', | ||
'status', | ||
'item.id', | ||
'item.name', | ||
'item.email', | ||
'items.0.id', | ||
'items.0.name', | ||
'items.0.email', | ||
]), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -389,7 +389,16 @@ public function testToArrayForArrayable(): void | |
$this->checkFixture($this->db, 'customer', true); | ||
|
||
$customerQuery = new ActiveQuery(CustomerForArrayable::class, $this->db); | ||
|
||
/** @var CustomerForArrayable $customer */ | ||
$customer = $customerQuery->findOne(1); | ||
/** @var CustomerForArrayable $customer2 */ | ||
$customer2 = $customerQuery->findOne(2); | ||
/** @var CustomerForArrayable $customer3 */ | ||
$customer3 = $customerQuery->findOne(3); | ||
|
||
$customer->setItem($customer2); | ||
$customer->setItems($customer3); | ||
|
||
$this->assertSame( | ||
[ | ||
|
@@ -398,10 +407,34 @@ public function testToArrayForArrayable(): void | |
'name' => 'user1', | ||
'address' => 'address1', | ||
'status' => 'active', | ||
'bool_status' => true, | ||
'profile_id' => 1, | ||
'item' => [ | ||
'id' => 2, | ||
'name' => 'user2', | ||
'email' => '[email protected]', | ||
'status' => 'active', | ||
], | ||
'items' => [ | ||
[ | ||
'id' => 3, | ||
'email' => '[email protected]', | ||
'name' => 'user3', | ||
'status' => 'inactive', | ||
], | ||
] | ||
], | ||
ArrayHelper::toArray($customer), | ||
$customer->toArray([ | ||
'id', | ||
'name', | ||
'email', | ||
'address', | ||
'status', | ||
'item.id', | ||
'item.name', | ||
'item.email', | ||
'items.0.id', | ||
'items.0.name', | ||
'items.0.email', | ||
]), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters