mirror of
https://github.com/anikeen-com/id.git
synced 2026-11-01 21:29:32 +00:00
The caches were undeclared properties: on an Eloquent model they went through Model::__set into the attributes, and save() failed with "no such column: ordersCache". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
32 lines
915 B
PHP
32 lines
915 B
PHP
<?php
|
|
|
|
namespace Anikeen\Id\Tests;
|
|
|
|
use Anikeen\Id\Billable;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class BillableModelTest extends TestCase
|
|
{
|
|
public function test_cached_api_results_are_not_model_attributes(): void
|
|
{
|
|
$user = new class extends Model {
|
|
use Billable;
|
|
|
|
protected $guarded = [];
|
|
|
|
public function cacheAll(): void
|
|
{
|
|
foreach (['addresses', 'countries', 'defaultPaymentMethod', 'invoices', 'orders', 'paymentMethods', 'subscriptions', 'transactions', 'userData'] as $name) {
|
|
$this->{$name.'Cache'} = 'cached';
|
|
}
|
|
}
|
|
};
|
|
$user->email = 'ada@example.com';
|
|
|
|
$user->cacheAll();
|
|
|
|
// save() would otherwise write them as columns ("no such column: ordersCache")
|
|
$this->assertSame(['email' => 'ada@example.com'], $user->getAttributes());
|
|
}
|
|
}
|