From 11aafbb2320c51bda8750c3454026ec502e05e45 Mon Sep 17 00:00:00 2001 From: Brandon Shipley Date: Sat, 14 Feb 2026 00:45:29 -0800 Subject: [PATCH] tests should be passing now --- .../Component/ShoppingCartComponentTest.php | 5 +- tests/bootstrap.php | 9 +-- tests/schema.sql | 60 +++++++++++++++++++ 3 files changed, 67 insertions(+), 7 deletions(-) create mode 100644 tests/schema.sql diff --git a/tests/TestCase/Controller/Component/ShoppingCartComponentTest.php b/tests/TestCase/Controller/Component/ShoppingCartComponentTest.php index 4ed7453..9f17b55 100644 --- a/tests/TestCase/Controller/Component/ShoppingCartComponentTest.php +++ b/tests/TestCase/Controller/Component/ShoppingCartComponentTest.php @@ -107,11 +107,10 @@ class ShoppingCartComponentTest extends TestCase { * @return void */ public function testCheckIfIsOwnCartIsNotOwnCart() { - $this->expectExceptionCode(404); - $cart = $this->fetchTable('Carts')->get('74d1aa54-92a2-4039-bc10-61e1190c51ec'); + $this->expectException(RecordNotFoundException::class); + $cart = $this->fetchTable('Carts')->get('00e6ec6b-eef8-429c-9196-e7e0668ba749'); $this->component->checkIfIsOwnCart($cart); // if exception not thrown test fails - $this->expectException(RecordNotFoundException::class); } } diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 51d1377..6ac5649 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -7,6 +7,7 @@ use Cake\Core\Configure; use Cake\Core\Plugin; use Cake\Database\Connection; use Cake\Datasource\ConnectionManager; +use Cake\TestSuite\Fixture\SchemaLoader; use CakeCarts\CakeCartsPlugin; use Migrations\TestSuite\Migrator; use TestApp\Controller\AppController; @@ -55,7 +56,7 @@ Configure::write('App', [ ], ]); -Configure::write('debug', true); +Configure::write('debug', false); Configure::write('CakeCarts', [ 'Carts' => [ 'table' => 'CakeCarts.Carts', @@ -120,8 +121,8 @@ ConnectionManager::setConfig('test', [ * and using \Migrations\TestSuite\Migrator to load schema. */ // Load a schema dump file. -//(new SchemaLoader())->loadSqlFiles('tests/schema.sql', 'test'); +(new SchemaLoader())->loadSqlFiles('tests/schema.sql', 'test'); -$migrator = new Migrator(); -$migrator->run(['plugin' => 'CakeCarts']); +//$migrator = new Migrator(); +//$migrator->run(['plugin' => 'CakeCarts']); diff --git a/tests/schema.sql b/tests/schema.sql new file mode 100644 index 0000000..3a87e79 --- /dev/null +++ b/tests/schema.sql @@ -0,0 +1,60 @@ +-- +-- Table structure for table `cart_items` +-- + +DROP TABLE IF EXISTS `cart_items`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `cart_items` ( + `id` char(36) NOT NULL, + `foreign_key` int(11) DEFAULT NULL, + `foreign_key_uuid` char(36) DEFAULT NULL, + `model` varchar(255) NOT NULL, + `cart_id` char(36) NOT NULL, + `position` int(11) DEFAULT NULL, + `qty` int(11) NOT NULL, + `price` decimal(13,5) DEFAULT NULL, + `subtotal` decimal(13,5) DEFAULT NULL, + PRIMARY KEY (`id`) +); +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `cart_items` +-- + +/*!40000 ALTER TABLE `cart_items` DISABLE KEYS */; +INSERT INTO `cart_items` VALUES ('08c9b023-a10d-4562-aea4-c64d357a1867',NULL,'3a477e3e-7977-4813-81f6-f85949613979','ProductSkus','00e6ec6b-eef8-429c-9196-e7e0668ba749',NULL,5,4.00000,20.00000),('11b6ef27-cabc-4afa-bae9-9644394c8b04',NULL,'a33a318f-84a8-48e4-aeff-b02afedfc91e','ProductSkus','d2928d3a-ea44-43b4-adaf-68f5f7924575',NULL,6,25.00000,150.00000),('32bce9d1-6602-4159-908e-ec6cd04181d6',NULL,'a302979b-bab0-49c8-8d3c-22118cf4e45b','ProductSkus','c1ced6bb-9d26-4882-ae74-444a834694cf',NULL,1,0.27400,0.27400),('60d28742-3d3f-4473-b381-8d56f75d9d12',NULL,'a33a318f-84a8-48e4-aeff-b02afedfc91e','ProductSkus','eb76c4e9-ba33-4f92-a160-a7c76dc9c0ed',NULL,2,1500.00000,3000.00000),('64e7ea02-cb89-41c9-9524-2edeff70515e',NULL,'a302979b-bab0-49c8-8d3c-22118cf4e45b','ProductSkus','c1ced6bb-9d26-4882-ae74-444a834694cf',NULL,51,0.27400,13.97400),('9f140892-654e-430c-871a-bb0402fa1689',NULL,'a33a318f-84a8-48e4-aeff-b02afedfc91e','ProductSkus','d2928d3a-ea44-43b4-adaf-68f5f7924575',NULL,1,NULL,0.00000); +/*!40000 ALTER TABLE `cart_items` ENABLE KEYS */; + +-- +-- Table structure for table `carts` +-- + +DROP TABLE IF EXISTS `carts`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `carts` ( + `id` char(36) NOT NULL, + `cart_type_id` int(11) NOT NULL, + `session_id` varchar(255) DEFAULT NULL, + `user_id` int(11) DEFAULT NULL, + `user_id_uuid` char(36) DEFAULT NULL, + `created` datetime NOT NULL, + `modified` datetime DEFAULT NULL, + `deleted` datetime DEFAULT NULL, + `removed` datetime DEFAULT NULL, + `removed_reason_id` int(11) DEFAULT NULL, + `num_items` int(11) NOT NULL DEFAULT 0, + PRIMARY KEY (`id`) +); +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `carts` +-- + +/*!40000 ALTER TABLE `carts` DISABLE KEYS */; +INSERT INTO `carts` VALUES ('00e6ec6b-eef8-429c-9196-e7e0668ba749',1,'40dbg7dq7t0a0kfl4ie29qa0r3',NULL,NULL,'2025-10-17 07:24:53','2025-10-17 07:24:53',NULL,NULL,NULL,0),('8f9ba579-84da-45a3-a23e-d4004eb17556',1,'9ustc5jbksfk2kn29t1r8ss4bi',NULL,NULL,'2025-11-02 01:41:32','2025-11-02 01:41:32',NULL,NULL,NULL,0),('980c731d-e543-43f8-a81e-bb2195f5783e',1,'d1c372spbgqm4236mlhmmetc0g',NULL,NULL,'2025-11-02 06:04:48','2025-11-02 06:04:48',NULL,NULL,NULL,0),('c1ced6bb-9d26-4882-ae74-444a834694cf',1,'lm091irggg9g4hoifgdbt9egj2',NULL,NULL,'2025-10-17 06:36:41','2025-10-17 06:36:41',NULL,NULL,NULL,0),('d2928d3a-ea44-43b4-adaf-68f5f7924575',1,'ueue6lvqrrbq913kg09momkddn',NULL,NULL,'2025-10-12 05:19:03','2025-10-12 05:19:03',NULL,NULL,NULL,0),('eb76c4e9-ba33-4f92-a160-a7c76dc9c0ed',1,'gt0c5hc8qutbg9d0mq5po6i1at',NULL,NULL,'2025-10-14 08:06:51','2025-10-14 08:06:51',NULL,NULL,NULL,0); +/*!40000 ALTER TABLE `carts` ENABLE KEYS */; +