diff --git a/mirzaev/baza/system/database.php b/mirzaev/baza/system/database.php index fff7192..5cad996 100755 --- a/mirzaev/baza/system/database.php +++ b/mirzaev/baza/system/database.php @@ -24,7 +24,10 @@ use LogicException as exception_logic, * @var encoding $encoding Encoding of records in the database file * @var array $columns The database columns * @var int $length Binary size of every record in the database file + * @var architecture $architecture PHP implementation architecture * + * @method void __construct() Constructor, initializes $architecture + @method void setArchitecture() Sets $architecture static property to PHP distribution architecture * @method self encoding(encoding $encoding) Write encoding into the database instance property (fluent interface) * @method self columns(column ...$columns) Write columns into the database instance property (fluent interface) * @method self connect(string $database) Initialize the database files (fluent interface) @@ -39,6 +42,7 @@ use LogicException as exception_logic, * * @license http://www.wtfpl.net Do What The Fuck You Want To Public License * @author Arsen Mirzaev Tatyano-Muradovich + * @author Little Fluffy Clouds */ class database { @@ -81,6 +85,50 @@ class database */ public protected(set) int $length; + /** + * Architecture + * + * @var architecture $architecture PHP implementation architecture + */ + public static architecture $architecture; + + /** + * Constructor + * + * Initializes $architecture static property to PHP distribution architecture + * + * @return void + */ + public function __construct() { + self::setArchitecture(); + } + + /** + * Set architecture + * + * Sets $architecture static property to PHP distribution architecture + * + * @throws exception_domain if PHP_INT_SIZE is set to abnormal value + * and PHP architecture can't be deducted from integer size + * + * @see https://www.php.net/manual/en/function.pack.php#109382 + * + * @return void + */ + + private static function setArchitecture(): void + { + if(isset(self::$architecture)) { + return; + } + + self::$architecture = match(PHP_INT_SIZE) { + 4 => architecture::x86, + 8 => architecture::x86_64, + default => throw new exception_domain('Failed to determine system architecture'), + }; + } + /** * Encoding * @@ -247,7 +295,7 @@ class database * we got to splice 64-bit integer into two separate longs * next to each other in binary representation */ - else if (core::architecture() === architecture::x86_64 && + else if (self::$architecture === architecture::x86_64 && ($column->type === type::integer || $column->type === type::integer_unsigned)) { @@ -317,7 +365,7 @@ p * PHP builtin pack() ignores 64-bit integer values * In case of integer type on 64-bit PHP distributions * we got to reconstruct previosly spliced integer value */ - else if (core::architecture() === architecture::x86_64 && + else if (self::$architecture === architecture::x86_64 && ($column->type === type::integer || $column->type === type::integer_unsigned)) { diff --git a/mirzaev/baza/system/enumerations/architecture.php b/mirzaev/baza/system/enumerations/architecture.php index cef1791..e319944 100644 --- a/mirzaev/baza/system/enumerations/architecture.php +++ b/mirzaev/baza/system/enumerations/architecture.php @@ -13,6 +13,7 @@ namespace mirzaev\baza\enumerations; * * @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License * @author Arsen Mirzaev Tatyano-Muradovich + * @author Little Fluffy Clouds */ enum architecture: int diff --git a/mirzaev/baza/tests/record.php b/mirzaev/baza/tests/record.php index 77ced11..6711f6d 100755 --- a/mirzaev/baza/tests/record.php +++ b/mirzaev/baza/tests/record.php @@ -3,7 +3,6 @@ declare(strict_types=1); use mirzaev\baza\database, - mirzaev\baza\core, mirzaev\baza\record, mirzaev\baza\column, mirzaev\baza\enumerations\encoding, @@ -36,9 +35,6 @@ require($autoload); // Initializing path to the database file $file = __DIR__ . DIRECTORY_SEPARATOR . 'temporary' . DIRECTORY_SEPARATOR . 'database.baza'; -// Initilized architecture runtime constant -define('ARCHITECTURE', core::architecture()); - echo "Started testing\n\n\n"; // Initializing the counter of actions @@ -57,9 +53,10 @@ if (!file_exists($file) || unlink($file)) { } // Initializing the test database -/* $database = new database() */ -if (ARCHITECTURE === architecture::x86_64) { - $database = (new database()) +$database = new database(); + +if ($database::$architecture === architecture::x86_64) { + $database ->encoding(encoding::utf8) ->columns( new column('name', type::string, ['length' => 32]), @@ -74,7 +71,7 @@ if (ARCHITECTURE === architecture::x86_64) { ) ->connect($file); } else { - $database = (new database()) + $database ->encoding(encoding::utf8) ->columns( new column('name', type::string, ['length' => 32]), @@ -89,7 +86,7 @@ if (ARCHITECTURE === architecture::x86_64) { echo '[' . ++$action . "] Initialized the database\n"; // Initializing the record -if (ARCHITECTURE === architecture::x86_64) { +if ($database::$architecture === architecture::x86_64) { $record = $database->record( 'Arsen', 'Mirzaev', @@ -119,7 +116,7 @@ echo '[' . ++$action . '][' . ++$test . '][' . ($record->name === 'Arsen' ? 'SUC echo '[' . $action . '][' . ++$test . '][' . ($record->second_name === 'Mirzaev' ? 'SUCCESS' : 'FAIL') . "][\"second_name\"] Expected: \"Mirzaev\" (string). Actual: \"$record->second_name\" (" . gettype($record->second_name) . ")\n"; echo '[' . $action . '][' . ++$test . '][' . ($record->age === 24 ? 'SUCCESS' : 'FAIL') . "][\"age\"] Expected: \"24\" (integer). Actual: \"$record->age\" (" . gettype($record->age) . ")\n"; echo '[' . $action . '][' . ++$test . '][' . ($record->height === 165.5 ? 'SUCCESS' : 'FAIL') . "][\"height\"] Expected: \"165.5\" (double). Actual: \"$record->height\" (" . gettype($record->height) . ")\n"; -if (ARCHITECTURE === architecture::x86_64) { +if ($database::$architecture === architecture::x86_64) { echo '[' . $action . '][' . ++$test . '][' . ($record->neuron_count === 91000000000 ? 'SUCCESS' : 'FAIL') . "][\"neuron_count\"] Expected: \"91000000000\" (integer). Actual: \"$record->neuron_count\" (" . gettype($record->neuron_count) . ")\n"; echo '[' . $action . '][' . ++$test . '][' . ($record->motivation === 1.7976931348623E+238 ? 'SUCCESS' : 'FAIL') . "][\"motivation\"] Expected: \"1.7976931348623E+238\" (double). Actual: \"$record->motivation\" (" . gettype($record->motivation) . ")\n"; echo '[' . $action . '][' . ++$test . '][' . ($record->reputation === 7355608 ? 'SUCCESS' : 'FAIL') . "][\"reputation\"] Expected: \"7355608\" (integer). Actual: \"$record->reputation\" (" . gettype($record->reputation) . ")\n"; @@ -134,10 +131,10 @@ $test = 0; // Writing the record into the database $database->write($record); -echo '[' . ++$action . "] Writed the record into the database\n"; +echo '[' . ++$action . "] Wrote the record into the database\n"; // Initializing the second record -if (ARCHITECTURE === architecture::x86_64) { +if ($database::$architecture === architecture::x86_64) { $record_ivan = $database->record( 'Ivan', 'Ivanov', @@ -166,7 +163,7 @@ $database->write($record_ivan); echo '[' . ++$action . "] Wrote the record into the database\n"; // Initializing the second record -if (ARCHITECTURE === architecture::x86_64) { +if ($database::$architecture === architecture::x86_64) { $record_margarita = $database->record( 'Margarita', 'Esenina', @@ -200,12 +197,12 @@ $records_read_all = $database->read(amount: 99999); echo '[' . ++$action . "] Read all records from the database\n"; try { - echo '[' . ++$action . '][' . ++$test . '][' . (gettype($records_readed_all) === 'array' ? 'SUCCESS' : 'FAIL') . '][type of returned value] Expected: "array". Actual: "' . gettype($records_readed_all) . "\"\n"; - echo '[' . $action . '][' . ++$test . '][' . (count($records_readed_all) === 3 ? 'SUCCESS' : 'FAIL') . '][amount of readed records] Expected: 3 records. Actual: ' . count($records_readed_all) . " records\n"; - echo '[' . $action . '][' . ++$test . '][' . (gettype($records_readed_all[0]) === 'object' ? 'SUCCESS' : 'FAIL') . '][type of readed values] Expected: "object". Actual: "' . gettype($records_readed_all[0]) . "\"\n"; - echo '[' . $action . '][' . ++$test . '][' . ($records_readed_all[0] instanceof record ? 'SUCCESS' : 'FAIL') . '][class of readed object values] Expected: "' . record::class . '". Actual: "' . $records_readed_all[0]::class . "\"\n"; - if (ARCHITECTURE === architecture::x86_64) { - echo '[' . $action . '][' . ++$test . '][' . ($records_readed_all[0]->neuron_count === 91000000000 ? 'SUCCESS' : 'FAIL') . ']["neuron_count"] Expected: "91000000000" (integer). Actual: "' . $records_readed_all[0]->neuron_count . '" (' . gettype($records_readed_all[0]->neuron_count) . ")\n"; + echo '[' . ++$action . '][' . ++$test . '][' . (gettype($records_read_all) === 'array' ? 'SUCCESS' : 'FAIL') . '][type of returned value] Expected: "array". Actual: "' . gettype($records_read_all) . "\"\n"; + echo '[' . $action . '][' . ++$test . '][' . (count($records_read_all) === 3 ? 'SUCCESS' : 'FAIL') . '][amount of read records] Expected: 3 records. Actual: ' . count($records_read_all) . " records\n"; + echo '[' . $action . '][' . ++$test . '][' . (gettype($records_read_all[0]) === 'object' ? 'SUCCESS' : 'FAIL') . '][type of read values] Expected: "object". Actual: "' . gettype($records_read_all[0]) . "\"\n"; + echo '[' . $action . '][' . ++$test . '][' . ($records_read_all[0] instanceof record ? 'SUCCESS' : 'FAIL') . '][class of read object values] Expected: "' . record::class . '". Actual: "' . $records_read_all[0]::class . "\"\n"; + if ($database::$architecture === architecture::x86_64) { + echo '[' . $action . '][' . ++$test . '][' . ($records_read_all[0]->neuron_count === 91000000000 ? 'SUCCESS' : 'FAIL') . ']["neuron_count"] Expected: "91000000000" (integer). Actual: "' . $records_read_all[0]->neuron_count . '" (' . gettype($records_read_all[0]->neuron_count) . ")\n"; } echo '[' . $action . "] The read all records checks have been completed\n"; @@ -222,13 +219,13 @@ $record_read_first = $database->read(amount: 1); echo '[' . ++$action . "] Read the first record from the database\n"; try { - echo '[' . ++$action . '][' . ++$test . '][' . (gettype($record_readed_first) === 'array' ? 'SUCCESS' : 'FAIL') . '][type of returned value] Expected: "array". Actual: "' . gettype($record_readed_first) . "\"\n"; - echo '[' . $action . '][' . ++$test . '][' . (count($record_readed_first) === 1 ? 'SUCCESS' : 'FAIL') . '][amount of readed records] Expected: 1 records. Actual: ' . count($record_readed_first) . " records\n"; - echo '[' . $action . '][' . ++$test . '][' . (gettype($record_readed_first[0]) === 'object' ? 'SUCCESS' : 'FAIL') . '][type of readed values] Expected: "object". Actual: "' . gettype($record_readed_first[0]) . "\"\n"; - echo '[' . $action . '][' . ++$test . '][' . ($record_readed_first[0] instanceof record ? 'SUCCESS' : 'FAIL') . '][class of readed object values] Expected: "' . record::class . '". Actual: "' . $record_readed_first[0]::class . "\"\n"; - echo '[' . $action . '][' . ++$test . '][' . ($record_readed_first[0]->second_name === 'Mirzaev' ? 'SUCCESS' : 'FAIL') . ']["second_name"] Expected: "Mirzaev" (string). Actual: "' . $record_readed_first[0]->second_name . '" (' . gettype($record_readed_first[0]->second_name) . ")\n"; - if (ARCHITECTURE === architecture::x86_64) { - echo '[' . $action . '][' . ++$test . '][' . ($record_readed_first[0]->neuron_count === 91000000000 ? 'SUCCESS' : 'FAIL') . ']["neuron_count"] Expected: "91000000000" (integer). Actual: "' . $record_readed_first[0]->neuron_count . '" (' . gettype($record_readed_first[0]->neuron_count) . ")\n"; + echo '[' . ++$action . '][' . ++$test . '][' . (gettype($record_read_first) === 'array' ? 'SUCCESS' : 'FAIL') . '][type of returned value] Expected: "array". Actual: "' . gettype($record_read_first) . "\"\n"; + echo '[' . $action . '][' . ++$test . '][' . (count($record_read_first) === 1 ? 'SUCCESS' : 'FAIL') . '][amount of read records] Expected: 1 records. Actual: ' . count($record_read_first) . " records\n"; + echo '[' . $action . '][' . ++$test . '][' . (gettype($record_read_first[0]) === 'object' ? 'SUCCESS' : 'FAIL') . '][type of read values] Expected: "object". Actual: "' . gettype($record_read_first[0]) . "\"\n"; + echo '[' . $action . '][' . ++$test . '][' . ($record_read_first[0] instanceof record ? 'SUCCESS' : 'FAIL') . '][class of read object values] Expected: "' . record::class . '". Actual: "' . $record_read_first[0]::class . "\"\n"; + echo '[' . $action . '][' . ++$test . '][' . ($record_read_first[0]->second_name === 'Mirzaev' ? 'SUCCESS' : 'FAIL') . ']["second_name"] Expected: "Mirzaev" (string). Actual: "' . $record_read_first[0]->second_name . '" (' . gettype($record_read_first[0]->second_name) . ")\n"; + if ($database::$architecture === architecture::x86_64) { + echo '[' . $action . '][' . ++$test . '][' . ($record_read_first[0]->neuron_count === 91000000000 ? 'SUCCESS' : 'FAIL') . ']["neuron_count"] Expected: "91000000000" (integer). Actual: "' . $record_read_first[0]->neuron_count . '" (' . gettype($record_read_first[0]->neuron_count) . ")\n"; } echo '[' . $action . "] The read first record checks have been completed\n"; @@ -245,12 +242,12 @@ $record_read_second = $database->read(amount: 1, offset: 1); echo '[' . ++$action . "] Read the second record from the database\n"; try { - echo '[' . ++$action . '][' . ++$test . '][' . (gettype($record_readed_second) === 'array' ? 'SUCCESS' : 'FAIL') . '][type of returned value] Expected: "array". Actual: "' . gettype($record_readed_second) . "\"\n"; - echo '[' . $action . '][' . ++$test . '][' . (count($record_readed_second) === 1 ? 'SUCCESS' : 'FAIL') . '][amount of readed records] Expected: 1 records. Actual: ' . count($record_readed_second) . " records\n"; - echo '[' . $action . '][' . ++$test . '][' . (gettype($record_readed_second[0]) === 'object' ? 'SUCCESS' : 'FAIL') . '][type of readed values] Expected: "object". Actual: "' . gettype($record_readed_second[0]) . "\"\n"; - echo '[' . $action . '][' . ++$test . '][' . ($record_readed_second[0] instanceof record ? 'SUCCESS' : 'FAIL') . '][class of readed object values] Expected: "' . record::class . '". Actual: "' . $record_readed_second[0]::class . "\"\n"; - echo '[' . $action . '][' . ++$test . '][' . ($record_readed_second[0]->second_name === 'Ivanov' ? 'SUCCESS' : 'FAIL') . ']["second_name"] Expected: "Ivanov" (string). Actual: "' . $record_readed_second[0]->second_name . '" (' . gettype($record_readed_second[0]->second_name) . ")\n"; - if (ARCHITECTURE === architecture::x86_64) { + echo '[' . ++$action . '][' . ++$test . '][' . (gettype($record_read_second) === 'array' ? 'SUCCESS' : 'FAIL') . '][type of returned value] Expected: "array". Actual: "' . gettype($record_read_second) . "\"\n"; + echo '[' . $action . '][' . ++$test . '][' . (count($record_read_second) === 1 ? 'SUCCESS' : 'FAIL') . '][amount of read records] Expected: 1 records. Actual: ' . count($record_read_second) . " records\n"; + echo '[' . $action . '][' . ++$test . '][' . (gettype($record_read_second[0]) === 'object' ? 'SUCCESS' : 'FAIL') . '][type of read values] Expected: "object". Actual: "' . gettype($record_read_second[0]) . "\"\n"; + echo '[' . $action . '][' . ++$test . '][' . ($record_read_second[0] instanceof record ? 'SUCCESS' : 'FAIL') . '][class of read object values] Expected: "' . record::class . '". Actual: "' . $record_read_second[0]::class . "\"\n"; + echo '[' . $action . '][' . ++$test . '][' . ($record_read_second[0]->second_name === 'Ivanov' ? 'SUCCESS' : 'FAIL') . ']["second_name"] Expected: "Ivanov" (string). Actual: "' . $record_read_second[0]->second_name . '" (' . gettype($record_read_second[0]->second_name) . ")\n"; + if ($database::$architecture === architecture::x86_64) { /** * Due to IEEE 754 double precision format double equality is problematic * @@ -274,12 +271,12 @@ $record_read_filter = $database->read(filter: fn($record) => $record?->second_na echo '[' . ++$action . "] Read the record from the database by filter\n"; try { - echo '[' . ++$action . '][' . ++$test . '][' . (gettype($record_readed_filter) === 'array' ? 'SUCCESS' : 'FAIL') . '][type of returned value] Expected: "array". Actual: "' . gettype($record_readed_filter) . "\"\n"; - echo '[' . $action . '][' . ++$test . '][' . (count($record_readed_filter) === 1 ? 'SUCCESS' : 'FAIL') . '][amount of readed records] Expected: 1 records. Actual: ' . count($record_readed_filter) . " records\n"; - echo '[' . $action . '][' . ++$test . '][' . (gettype($record_readed_filter[0]) === 'object' ? 'SUCCESS' : 'FAIL') . '][type of readed values] Expected: "object". Actual: "' . gettype($record_readed_filter[0]) . "\"\n"; - echo '[' . $action . '][' . ++$test . '][' . ($record_readed_filter[0] instanceof record ? 'SUCCESS' : 'FAIL') . '][class of readed object values] Expected: "' . record::class . '". Actual: "' . $record_readed_filter[0]::class . "\"\n"; - echo '[' . $action . '][' . ++$test . '][' . ($record_readed_filter[0]->second_name === 'Ivanov' ? 'SUCCESS' : 'FAIL') . ']["second_name"] Expected: "Ivanov" (string). Actual: "' . $record_readed_filter[0]->second_name . '" (' . gettype($record_readed_filter[0]->second_name) . ")\n"; - if (ARCHITECTURE === architecture::x86_64) { + echo '[' . ++$action . '][' . ++$test . '][' . (gettype($record_read_filter) === 'array' ? 'SUCCESS' : 'FAIL') . '][type of returned value] Expected: "array". Actual: "' . gettype($record_read_filter) . "\"\n"; + echo '[' . $action . '][' . ++$test . '][' . (count($record_read_filter) === 1 ? 'SUCCESS' : 'FAIL') . '][amount of read records] Expected: 1 records. Actual: ' . count($record_read_filter) . " records\n"; + echo '[' . $action . '][' . ++$test . '][' . (gettype($record_read_filter[0]) === 'object' ? 'SUCCESS' : 'FAIL') . '][type of read values] Expected: "object". Actual: "' . gettype($record_read_filter[0]) . "\"\n"; + echo '[' . $action . '][' . ++$test . '][' . ($record_read_filter[0] instanceof record ? 'SUCCESS' : 'FAIL') . '][class of read object values] Expected: "' . record::class . '". Actual: "' . $record_read_filter[0]::class . "\"\n"; + echo '[' . $action . '][' . ++$test . '][' . ($record_read_filter[0]->second_name === 'Ivanov' ? 'SUCCESS' : 'FAIL') . ']["second_name"] Expected: "Ivanov" (string). Actual: "' . $record_read_filter[0]->second_name . '" (' . gettype($record_read_filter[0]->second_name) . ")\n"; + if ($database::$architecture === architecture::x86_64) { /** * Due to IEEE 754 double precision format double equality is problematic * @@ -303,13 +300,13 @@ $records_read_filter_amount = $database->read(filter: fn($record) => $record?->a echo '[' . ++$action . "] Read the record from the database by filter with amount limit\n"; try { - echo '[' . ++$action . '][' . ++$test . '][' . (gettype($records_readed_filter_amount) === 'array' ? 'SUCCESS' : 'FAIL') . '][type of returned value] Expected: "array". Actual: "' . gettype($records_readed_filter_amount) . "\"\n"; - echo '[' . $action . '][' . ++$test . '][' . (count($records_readed_filter_amount) === 1 ? 'SUCCESS' : 'FAIL') . '][amount of readed records] Expected: 1 records. Actual: ' . count($records_readed_filter_amount) . " records\n"; - echo '[' . $action . '][' . ++$test . '][' . (gettype($records_readed_filter_amount[0]) === 'object' ? 'SUCCESS' : 'FAIL') . '][type of readed values] Expected: "object". Actual: "' . gettype($records_readed_filter_amount[0]) . "\"\n"; - echo '[' . $action . '][' . ++$test . '][' . ($records_readed_filter_amount[0] instanceof record ? 'SUCCESS' : 'FAIL') . '][class of readed object values] Expected: "' . record::class . '". Actual: "' . $records_readed_filter_amount[0]::class . "\"\n"; - echo '[' . $action . '][' . ++$test . '][' . ($records_readed_filter_amount[0]->age === 24 ? 'SUCCESS' : 'FAIL') . ']["age"] Expected: "24" (integer). Actual: "' . $records_readed_filter_amount[0]->age . '" (' . gettype($records_readed_filter_amount[0]->age) . ")\n"; - echo '[' . $action . '][' . ++$test . '][' . ($records_readed_filter_amount[0]->second_name === 'Mirzaev' ? 'SUCCESS' : 'FAIL') . ']["second_name"] Expected: "Mirzaev" (string). Actual: "' . $records_readed_filter_amount[0]->second_name . '" (' . gettype($records_readed_filter_amount[0]->second_name) . ")\n"; - if (ARCHITECTURE === architecture::x86_64) { + echo '[' . ++$action . '][' . ++$test . '][' . (gettype($records_read_filter_amount) === 'array' ? 'SUCCESS' : 'FAIL') . '][type of returned value] Expected: "array". Actual: "' . gettype($records_read_filter_amount) . "\"\n"; + echo '[' . $action . '][' . ++$test . '][' . (count($records_read_filter_amount) === 1 ? 'SUCCESS' : 'FAIL') . '][amount of read records] Expected: 1 records. Actual: ' . count($records_read_filter_amount) . " records\n"; + echo '[' . $action . '][' . ++$test . '][' . (gettype($records_read_filter_amount[0]) === 'object' ? 'SUCCESS' : 'FAIL') . '][type of read values] Expected: "object". Actual: "' . gettype($records_read_filter_amount[0]) . "\"\n"; + echo '[' . $action . '][' . ++$test . '][' . ($records_read_filter_amount[0] instanceof record ? 'SUCCESS' : 'FAIL') . '][class of read object values] Expected: "' . record::class . '". Actual: "' . $records_read_filter_amount[0]::class . "\"\n"; + echo '[' . $action . '][' . ++$test . '][' . ($records_read_filter_amount[0]->age === 24 ? 'SUCCESS' : 'FAIL') . ']["age"] Expected: "24" (integer). Actual: "' . $records_read_filter_amount[0]->age . '" (' . gettype($records_read_filter_amount[0]->age) . ")\n"; + echo '[' . $action . '][' . ++$test . '][' . ($records_read_filter_amount[0]->second_name === 'Mirzaev' ? 'SUCCESS' : 'FAIL') . ']["second_name"] Expected: "Mirzaev" (string). Actual: "' . $records_read_filter_amount[0]->second_name . '" (' . gettype($records_read_filter_amount[0]->second_name) . ")\n"; + if ($database::$architecture === architecture::x86_64) { /** * Due to IEEE 754 double precision format double equality is problematic * @@ -333,13 +330,13 @@ $records_read_filter_amount_offset = $database->read(filter: fn($record) => $rec echo '[' . ++$action . "] Read the record from the database by filter with amount limit and offset\n"; try { - echo '[' . ++$action . '][' . ++$test . '][' . (gettype($records_readed_filter_amount_offset) === 'array' ? 'SUCCESS' : 'FAIL') . '][type of returned value] Expected: "array". Actual: "' . gettype($records_readed_filter_amount_offset) . "\"\n"; - echo '[' . $action . '][' . ++$test . '][' . (count($records_readed_filter_amount_offset) === 1 ? 'SUCCESS' : 'FAIL') . '][amount of readed records] Expected: 1 records. Actual: ' . count($records_readed_filter_amount_offset) . " records\n"; - echo '[' . $action . '][' . ++$test . '][' . (gettype($records_readed_filter_amount_offset[0]) === 'object' ? 'SUCCESS' : 'FAIL') . '][type of readed values] Expected: "object". Actual: "' . gettype($records_readed_filter_amount_offset[0]) . "\"\n"; - echo '[' . $action . '][' . ++$test . '][' . ($records_readed_filter_amount_offset[0] instanceof record ? 'SUCCESS' : 'FAIL') . '][class of readed object values] Expected: "' . record::class . '". Actual: "' . $records_readed_filter_amount_offset[0]::class . "\"\n"; - echo '[' . $action . '][' . ++$test . '][' . ($records_readed_filter_amount_offset[0]->age === 24 ? 'SUCCESS' : 'FAIL') . ']["age"] Expected: "24" (integer). Actual: "' . $records_readed_filter_amount_offset[0]->age . '" (' . gettype($records_readed_filter_amount_offset[0]->age) . ")\n"; - echo '[' . $action . '][' . ++$test . '][' . ($records_readed_filter_amount_offset[0]->second_name === 'Ivanov' ? 'SUCCESS' : 'FAIL') . ']["second_name"] Expected: "Ivanov" (string). Actual: "' . $records_readed_filter_amount_offset[0]->second_name . '" (' . gettype($records_readed_filter_amount_offset[0]->second_name) . ")\n"; - if (ARCHITECTURE === architecture::x86_64) { + echo '[' . ++$action . '][' . ++$test . '][' . (gettype($records_read_filter_amount_offset) === 'array' ? 'SUCCESS' : 'FAIL') . '][type of returned value] Expected: "array". Actual: "' . gettype($records_read_filter_amount_offset) . "\"\n"; + echo '[' . $action . '][' . ++$test . '][' . (count($records_read_filter_amount_offset) === 1 ? 'SUCCESS' : 'FAIL') . '][amount of read records] Expected: 1 records. Actual: ' . count($records_read_filter_amount_offset) . " records\n"; + echo '[' . $action . '][' . ++$test . '][' . (gettype($records_read_filter_amount_offset[0]) === 'object' ? 'SUCCESS' : 'FAIL') . '][type of read values] Expected: "object". Actual: "' . gettype($records_read_filter_amount_offset[0]) . "\"\n"; + echo '[' . $action . '][' . ++$test . '][' . ($records_read_filter_amount_offset[0] instanceof record ? 'SUCCESS' : 'FAIL') . '][class of read object values] Expected: "' . record::class . '". Actual: "' . $records_read_filter_amount_offset[0]::class . "\"\n"; + echo '[' . $action . '][' . ++$test . '][' . ($records_read_filter_amount_offset[0]->age === 24 ? 'SUCCESS' : 'FAIL') . ']["age"] Expected: "24" (integer). Actual: "' . $records_read_filter_amount_offset[0]->age . '" (' . gettype($records_read_filter_amount_offset[0]->age) . ")\n"; + echo '[' . $action . '][' . ++$test . '][' . ($records_read_filter_amount_offset[0]->second_name === 'Ivanov' ? 'SUCCESS' : 'FAIL') . ']["second_name"] Expected: "Ivanov" (string). Actual: "' . $records_read_filter_amount_offset[0]->second_name . '" (' . gettype($records_read_filter_amount_offset[0]->second_name) . ")\n"; + if ($database::$architecture === architecture::x86_64) { /** * Due to IEEE 754 double precision format double equality is problematic * @@ -368,20 +365,20 @@ $records_read_filter_delete_read = $database->read(amount: 100); echo '[' . ++$action . "] Read records from the database after deleting the record\n"; try { - echo '[' . ++$action . '][' . ++$test . '][' . (gettype($records_readed_filter_delete) === 'array' ? 'SUCCESS' : 'FAIL') . '][type of returned value] Expected: "array". Actual: "' . gettype($records_readed_filter_delete) . "\"\n"; - echo '[' . $action . '][' . ++$test . '][' . (count($records_readed_filter_delete) === 1 ? 'SUCCESS' : 'FAIL') . '][amount of deleted records] Expected: 1 records. Actual: ' . count($records_readed_filter_delete) . " records\n"; - echo '[' . $action . '][' . ++$test . '][' . (gettype($records_readed_filter_delete[0]) === 'object' ? 'SUCCESS' : 'FAIL') . '][type of readed values] Expected: "object". Actual: "' . gettype($records_readed_filter_delete[0]) . "\"\n"; - echo '[' . $action . '][' . ++$test . '][' . ($records_readed_filter_delete[0] instanceof record ? 'SUCCESS' : 'FAIL') . '][class of readed object values] Expected: "' . record::class . '". Actual: "' . $records_readed_filter_delete[0]::class . "\"\n"; - echo '[' . $action . '][' . ++$test . '][' . ($records_readed_filter_delete[0]->name === 'Ivan' ? 'SUCCESS' : 'FAIL') . ']["name"] Expected: "Ivan" (string). Actual: "' . $records_readed_filter_delete[0]->second_name . '" (' . gettype($records_readed_filter_delete[0]->second_name) . ")\n"; - echo '[' . $action . '][' . ++$test . '][' . (count($records_readed_filter_delete_readed) === 2 ? 'SUCCESS' : 'FAIL') . '][amount of readed records after deleting] Expected: 2 records. Actual: ' . count($records_readed_filter_delete_readed) . " records\n"; - if (ARCHITECTURE === architecture::x86_64) { + echo '[' . ++$action . '][' . ++$test . '][' . (gettype($records_read_filter_delete) === 'array' ? 'SUCCESS' : 'FAIL') . '][type of returned value] Expected: "array". Actual: "' . gettype($records_read_filter_delete) . "\"\n"; + echo '[' . $action . '][' . ++$test . '][' . (count($records_read_filter_delete) === 1 ? 'SUCCESS' : 'FAIL') . '][amount of deleted records] Expected: 1 records. Actual: ' . count($records_read_filter_delete) . " records\n"; + echo '[' . $action . '][' . ++$test . '][' . (gettype($records_read_filter_delete[0]) === 'object' ? 'SUCCESS' : 'FAIL') . '][type of read values] Expected: "object". Actual: "' . gettype($records_read_filter_delete[0]) . "\"\n"; + echo '[' . $action . '][' . ++$test . '][' . ($records_read_filter_delete[0] instanceof record ? 'SUCCESS' : 'FAIL') . '][class of read object values] Expected: "' . record::class . '". Actual: "' . $records_read_filter_delete[0]::class . "\"\n"; + echo '[' . $action . '][' . ++$test . '][' . ($records_read_filter_delete[0]->name === 'Ivan' ? 'SUCCESS' : 'FAIL') . ']["name"] Expected: "Ivan" (string). Actual: "' . $records_read_filter_delete[0]->second_name . '" (' . gettype($records_read_filter_delete[0]->second_name) . ")\n"; + echo '[' . $action . '][' . ++$test . '][' . (count($records_read_filter_delete_read) === 2 ? 'SUCCESS' : 'FAIL') . '][amount of read records after deleting] Expected: 2 records. Actual: ' . count($records_read_filter_delete_read) . " records\n"; + if ($database::$architecture === architecture::x86_64) { /** * Due to IEEE 754 double precision format double equality is problematic * * @see https://www.php.net/manual/en/language.types.float.php#113703 */ - echo '[' . $action . '][' . ++$test . '][' . (round($records_readed_filter_delete_readed[1]->motivation, 2) === round(163, 2) ? 'SUCCESS' : 'FAIL') . ']["motivation"] Expected: "163" (double). Actual: "' . $records_readed_filter_delete_readed[1]->motivation . '" (' . gettype($records_readed_filter_delete_readed[1]->motivation) . ")\n"; - echo '[' . $action . '][' . ++$test . '][' . ($records_readed_filter_delete_readed[1]->reputation === (int) 9223372036854775807 ? 'SUCCESS' : 'FAIL') . ']["reputation"] Expected: "9223372036854775807" (integer). Actual: "' . $records_readed_filter_delete_readed[1]->reputation . '" (' . gettype($records_readed_filter_delete_readed[1]->reputation) . ")\n"; + echo '[' . $action . '][' . ++$test . '][' . (round($records_read_filter_delete_read[1]->motivation, 2) === round(163, 2) ? 'SUCCESS' : 'FAIL') . ']["motivation"] Expected: "163" (double). Actual: "' . $records_read_filter_delete_read[1]->motivation . '" (' . gettype($records_read_filter_delete_read[1]->motivation) . ")\n"; + echo '[' . $action . '][' . ++$test . '][' . ($records_read_filter_delete_read[1]->reputation === (int) 9223372036854775807 ? 'SUCCESS' : 'FAIL') . ']["reputation"] Expected: "9223372036854775807" (integer). Actual: "' . $records_read_filter_delete_read[1]->reputation . '" (' . gettype($records_read_filter_delete_read[1]->reputation) . ")\n"; } echo '[' . $action . "] The deleted record by filter checks have been completed\n"; @@ -403,14 +400,14 @@ $records_read_filter_update_read = $database->read(amount: 100); echo '[' . ++$action . "] Read records from the database after updating the record\n"; try { - echo '[' . ++$action . '][' . ++$test . '][' . (gettype($records_readed_filter_update) === 'array' ? 'SUCCESS' : 'FAIL') . '][type of returned value] Expected: "array". Actual: "' . gettype($records_readed_filter_update) . "\"\n"; - echo '[' . $action . '][' . ++$test . '][' . (count($records_readed_filter_update) === 1 ? 'SUCCESS' : 'FAIL') . '][amount of updated records] Expected: 1 records. Actual: ' . count($records_readed_filter_update) . " records\n"; - echo '[' . $action . '][' . ++$test . '][' . (gettype($records_readed_filter_update[0]) === 'object' ? 'SUCCESS' : 'FAIL') . '][type of readed values] Expected: "object". Actual: "' . gettype($records_readed_filter_update[0]) . "\"\n"; - echo '[' . $action . '][' . ++$test . '][' . ($records_readed_filter_update[0] instanceof record ? 'SUCCESS' : 'FAIL') . '][class of readed object values] Expected: "' . record::class . '". Actual: "' . $records_readed_filter_update[0]::class . "\"\n"; - echo '[' . $action . '][' . ++$test . '][' . ($records_readed_filter_update[0]->height === 165.5 ? 'SUCCESS' : 'FAIL') . ']["height"] Expected: "165.5" (double). Actual: "' . $records_readed_filter_update[0]->height . '" (' . gettype($records_readed_filter_update[0]->height) . ")\n"; - echo '[' . $action . '][' . ++$test . '][' . (count($records_readed_filter_update_readed) === 2 ? 'SUCCESS' : 'FAIL') . '][amount of readed records after updating] Expected: 2 records. Actual: ' . count($records_readed_filter_update_readed) . " records\n"; - echo '[' . $action . '][' . ++$test . '][' . ($records_readed_filter_update_readed[1]->height === $records_readed_filter_update[0]->height ? 'SUCCESS' : 'FAIL') . "] Height from `update` process response matched height from the `read` preocess response\n"; - if (ARCHITECTURE === architecture::x86_64) { + echo '[' . ++$action . '][' . ++$test . '][' . (gettype($records_read_filter_update) === 'array' ? 'SUCCESS' : 'FAIL') . '][type of returned value] Expected: "array". Actual: "' . gettype($records_read_filter_update) . "\"\n"; + echo '[' . $action . '][' . ++$test . '][' . (count($records_read_filter_update) === 1 ? 'SUCCESS' : 'FAIL') . '][amount of updated records] Expected: 1 records. Actual: ' . count($records_read_filter_update) . " records\n"; + echo '[' . $action . '][' . ++$test . '][' . (gettype($records_read_filter_update[0]) === 'object' ? 'SUCCESS' : 'FAIL') . '][type of read values] Expected: "object". Actual: "' . gettype($records_read_filter_update[0]) . "\"\n"; + echo '[' . $action . '][' . ++$test . '][' . ($records_read_filter_update[0] instanceof record ? 'SUCCESS' : 'FAIL') . '][class of read object values] Expected: "' . record::class . '". Actual: "' . $records_read_filter_update[0]::class . "\"\n"; + echo '[' . $action . '][' . ++$test . '][' . ($records_read_filter_update[0]->height === 165.5 ? 'SUCCESS' : 'FAIL') . ']["height"] Expected: "165.5" (double). Actual: "' . $records_read_filter_update[0]->height . '" (' . gettype($records_read_filter_update[0]->height) . ")\n"; + echo '[' . $action . '][' . ++$test . '][' . (count($records_read_filter_update_read) === 2 ? 'SUCCESS' : 'FAIL') . '][amount of read records after updating] Expected: 2 records. Actual: ' . count($records_read_filter_update_read) . " records\n"; + echo '[' . $action . '][' . ++$test . '][' . ($records_read_filter_update_read[1]->height === $records_read_filter_update[0]->height ? 'SUCCESS' : 'FAIL') . "] Height from `update` process response matched height from the `read` preocess response\n"; + if ($database::$architecture === architecture::x86_64) { /** * Due to IEEE 754 double precision format double equality is problematic *