@@ -15,7 +15,12 @@ final class ReceiptStockMovement
|
||||
$root = base_path('packages/inventory-write/releases/0.1.0');
|
||||
$pin = 'f0b99e591f9a4df135e685f64ceffad77bed259222debe0f34c20f95e3cad800';
|
||||
$files = ['bootstrap.php', 'src/ReceiptMovementWriter.php'];
|
||||
if (config('inventory_conversion.qa_enabled') === true) {
|
||||
$conversion = app(InventoryConversionRuntime::class);
|
||||
if ($conversion->enabled()) {
|
||||
$root = $conversion->root();
|
||||
$pin = InventoryConversionRuntime::MANIFEST_SHA256;
|
||||
$files[] = 'src/QuantityConversion.php';
|
||||
} elseif (config('inventory_conversion.qa_enabled') === true) {
|
||||
abort_unless(app()->environment('testing'), 503, 'Extensão de conversão limitada a QA.');
|
||||
$connection = DB::connection();
|
||||
abort_unless(($connection->getDriverName() === 'sqlite' && $connection->getDatabaseName() === ':memory:')
|
||||
@@ -23,6 +28,8 @@ final class ReceiptStockMovement
|
||||
$root = base_path('packages/inventory-write/development');
|
||||
$pin = '90cf565537e7fd48eb54a87bcfd6d585cf53239f075764910047838b3b8b4c38';
|
||||
$files[] = 'src/QuantityConversion.php';
|
||||
} else {
|
||||
$conversion->assertLegacyCompatible();
|
||||
}
|
||||
$bytes = is_file($root.'/manifest.json') ? file_get_contents($root.'/manifest.json') : false;
|
||||
if (! is_string($bytes) || ! hash_equals($pin, hash('sha256', $bytes))) {
|
||||
@@ -35,9 +42,16 @@ final class ReceiptStockMovement
|
||||
throw new \LogicException('Pacote de recepção alterado.');
|
||||
}
|
||||
}
|
||||
if (class_exists(ReceiptMovementWriter::class, false)) {
|
||||
$loaded = (new \ReflectionClass(ReceiptMovementWriter::class))->getFileName();
|
||||
if (! is_string($loaded) || realpath($loaded) !== realpath($root.'/src/ReceiptMovementWriter.php')) {
|
||||
foreach (['ReceiptMovementWriter', 'QuantityConversion'] as $class) {
|
||||
if ($class === 'QuantityConversion' && ! in_array('src/QuantityConversion.php', $files, true)) {
|
||||
continue;
|
||||
}
|
||||
$name = 'Tempo\\Inventory\\'.$class;
|
||||
if (! class_exists($name, false)) {
|
||||
continue;
|
||||
}
|
||||
$loaded = (new \ReflectionClass($name))->getFileName();
|
||||
if (! is_string($loaded) || realpath($loaded) !== realpath($root.'/src/'.$class.'.php')) {
|
||||
throw new \LogicException('Escritor já carregado de outra versão; use um kernel QA separado.');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user